Skip to content

Commit

Permalink
theme: remove code for older hugo versions #679
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Nov 26, 2023
1 parent f9887d1 commit 0d51f64
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 43 deletions.
6 changes: 0 additions & 6 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $id := "" }}
{{- if or (and (eq $major 0) (ge $minor 108)) (gt $major 0) }}
{{- $id = "" }}
{{- end }}
{{- partial "shortcodes/image.html" (dict
"page" .Page
"url" .Destination
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{{- $basename = partial "BaseName.hugo" $format.RelPermalink }}
{{- end }}
{{- if eq . .Site.Sites.First.Home }}
{{- $minHugoVersion := "0.110.0" }}
{{- if lt hugo.Version $minHugoVersion }}
{{- errorf "The Relearn theme requires Hugo %s or later" $minHugoVersion }}
{{- $hugoVersion := "0.110.0" }}
{{- if lt hugo.Version $hugoVersion }}
{{- errorf "The Relearn theme requires Hugo %s or later" $hugoVersion }}
{{- end }}
{{- end }}
<html lang="{{ .Page.Language | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
Expand Down
9 changes: 4 additions & 5 deletions layouts/partials/shortcodes/attachments.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
Expand Down Expand Up @@ -43,7 +40,8 @@
{{- $urlPrefix := strings.TrimRight "/" $page.RelPermalink }}
{{- with $page }}
{{- if ne .BundleType "leaf" }}
{{- if or (and (eq $major 0) (ge $minor 112)) (gt $major 0) }}
{{- $hugoVersion := "0.112.0" }}
{{- if ge hugo.Version $hugoVersion }}
{{- warnf "%q: UNSUPPORTED usage of 'attachments' shortcode found while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Filename }}
{{- else }}
{{- warnf "%q: DEPRECATED usage of 'attachments' shortcode found which will not be compatible while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Filename }}
Expand All @@ -53,7 +51,8 @@
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | .RenderString }}</div>
<ul class="box-content attachments-files">
{{- $fileDir := "" }}
{{- if or (and (eq $major 0) (ge $minor 112)) (gt $major 0) }}
{{- $hugoVersion := "0.112.0" }}
{{- if ge hugo.Version $hugoVersion }}
{{- $fileDir = path.Dir (strings.TrimPrefix (path.Clean hugo.WorkingDir) (path.Clean .File.Filename)) }}
{{- else }}
{{- $fileDir = printf "%s/%s" (path.Clean (.Language.ContentDir | default "content")) (path.Clean .File.Dir) }}
Expand Down
6 changes: 0 additions & 6 deletions layouts/shortcodes/expand.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{{- $_hugo_config := `{ "version": 1 }` }}
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $id := "" }}
{{- if or (and (eq $major 0) (ge $minor 108)) (gt $major 0) }}
{{- $id = "" }}
{{- end }}
{{- partial "shortcodes/expand.html" (dict
"page" .Page
"content" .Inner
Expand Down
9 changes: 1 addition & 8 deletions layouts/shortcodes/highlight.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $content := "" }}
{{- if or (and (eq $major 0) (ge $minor 110)) (gt $major 0) }}
{{- $content = .InnerDeindent }}
{{- else }}
{{- $content = .Inner }}
{{- end }}
{{- $content = .InnerDeindent }}
{{- $attributes := dict }}
{{- $options := dict }}
{{- $type := "" }}
Expand Down
6 changes: 0 additions & 6 deletions layouts/shortcodes/openapi.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $id := "" }}
{{- if or (and (eq $major 0) (ge $minor 108)) (gt $major 0) }}
{{- $id = "" }}
{{- end }}
{{- partial "shortcodes/openapi.html" (dict
"page" .Page
"src" (.Get "src")
Expand Down
6 changes: 0 additions & 6 deletions layouts/shortcodes/swagger.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $id := "" }}
{{- if or (and (eq $major 0) (ge $minor 108)) (gt $major 0) }}
{{- $id = "" }}
{{- end }}
{{- partial "shortcodes/swagger.html" (dict
"page" .Page
"src" (.Get "src")
Expand Down
3 changes: 0 additions & 3 deletions layouts/shortcodes/tabs.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{{- $unused := .Inner }}
{{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }}
{{- $color := (.Get "color") }}
{{- $groupid := ((.Get "groupid") | default (.Get "groupId")) }}
{{- if (.Get "groupId") }}
Expand Down

0 comments on commit 0d51f64

Please sign in to comment.