initial commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{{- $authorName := "" }}
|
||||
{{- with .Site.Params.author }}
|
||||
{{- if reflect.IsMap . }}
|
||||
{{- with .name }}
|
||||
{{- $authorName = . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- warnf "DEPRECATED usage of 'params.author' config parameter found, replace it with `params.author.name` in your hugo.toml; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-23-0" }}
|
||||
{{- $authorName = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $authorName }}
|
||||
@@ -0,0 +1,35 @@
|
||||
{{- $style := lower .style }}
|
||||
{{- $set := "" }}
|
||||
{{- range site.Params.boxStyle }}
|
||||
{{- if eq (lower .identifier) $style }}
|
||||
{{- $title := or .title (.i18n | T) }}
|
||||
{{- $set = dict "style" $style "title" $title "icon" .icon }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not $set }}
|
||||
{{- range (slice
|
||||
(dict "identifier" "caution" "icon" "hand")
|
||||
(dict "identifier" "important" "icon" "bolt")
|
||||
(dict "identifier" "info" "icon" "info-circle")
|
||||
(dict "identifier" "note" "icon" "exclamation-circle")
|
||||
(dict "identifier" "tip" "icon" "lightbulb")
|
||||
(dict "identifier" "warning" "icon" "exclamation-triangle")
|
||||
) }}
|
||||
{{- if eq .identifier $style }}
|
||||
{{- $title := .identifier | T }}
|
||||
{{- $set = dict "style" $style "title" $title "icon" .icon }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not $set }}
|
||||
{{- $set = dict "style" $style "title" "" "icon" "" }}
|
||||
{{- end }}
|
||||
{{- if .title }}
|
||||
{{- $set = merge $set (dict "title" .title) }}
|
||||
{{- end }}
|
||||
{{- if .icon }}
|
||||
{{- $set = merge $set (dict "icon" .icon) }}
|
||||
{{- end }}
|
||||
{{- return $set }}
|
||||
@@ -0,0 +1,57 @@
|
||||
{{- $href := partial "permalink.gotmpl" (dict "to" .linkObject) }}
|
||||
{{- $silent := .silent | default false }}
|
||||
{{- $hideFilepath := .hideFilepath | default false }}
|
||||
{{- $u := urls.Parse .url }}
|
||||
{{- with $u.RawQuery }}
|
||||
{{- $href = printf "%s?%s" $href . }}
|
||||
{{- end }}
|
||||
{{- with $u.Fragment }}
|
||||
{{- $href = printf "%s#%s" $href . }}
|
||||
{{- if not $silent }}
|
||||
{{- partial "inline/validate-fragment.html" (dict "origPage" $.page "page" $.linkObject "parsedURL" $u "url" $.url "param" $.param "hideFilepath" $hideFilepath) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $href }}
|
||||
|
||||
{{- define "partials/inline/validate-fragment.html" }}
|
||||
{{- /*
|
||||
Validates the fragment portion of a link destination.
|
||||
*/}}
|
||||
|
||||
{{- /* Initialize. */}}
|
||||
{{- $errorLevel := .errorLevel }}
|
||||
{{- $origPage := .origPage }}
|
||||
{{- $p := .page }}
|
||||
{{- $url := .url }}
|
||||
{{- $u := .parsedURL }}
|
||||
{{- $param := .param }}
|
||||
{{- $hideFilepath := .hideFilepath }}
|
||||
|
||||
{{- /* Validate. */}}
|
||||
{{- with $u.Fragment }}
|
||||
{{- if $p.Fragments.Identifiers.Contains . }}
|
||||
{{- if gt ($p.Fragments.Identifiers.Count .) 1 }}
|
||||
{{- $filepath := "[virtual file]" }}{{ with and $origPage $origPage.File $origPage.File.Filename }}{{ $filepath = . }}{{ end }}
|
||||
{{- $msg := printf "%q: duplicate heading ID %q found" $filepath . }}
|
||||
{{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" $url "page" $origPage "param" $param "msg" $msg) }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- /* Determine target path for warning and error message. */}}
|
||||
{{- $targetPath := "" }}
|
||||
{{- with $p.File }}
|
||||
{{- $targetPath = .Path }}
|
||||
{{- else }}
|
||||
{{- $targetPath = .Path }}
|
||||
{{- end }}
|
||||
{{- $filepath := "[virtual file]" }}{{ with and $origPage $origPage.File $origPage.File.Filename }}{{ $filepath = . }}{{ end }}
|
||||
{{- $msg := printf "heading ID %q not found" . }}
|
||||
{{- if not $hideFilepath }}
|
||||
{{- $msg = printf "%q: %s" $filepath $msg }}
|
||||
{{- end }}
|
||||
{{- if or $hideFilepath (ne $origPage $p) }}
|
||||
{{- $msg = printf "%s in %q" $msg $targetPath }}
|
||||
{{- end }}
|
||||
{{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" $url "page" $origPage "param" $param "msg" $msg) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,40 @@
|
||||
{{- range .Site.Params.relearn.dependencies }}
|
||||
{{- $has := printf "has%s" .name }}
|
||||
{{- $disable := printf "disable%s" .name }}
|
||||
{{- $enable := printf "%s" (lower .name) }}
|
||||
|
||||
{{- $wantsPage := false }}
|
||||
{{- $filepath := "[virtual file]" }}{{ with and $.File $.File.Filename }}{{ $filepath = . }}{{ end }}
|
||||
{{- if ne (index $.Params $disable) nil }}
|
||||
{{- $wantsPage = not (index $.Params $disable) }}
|
||||
{{- warnf "%q: DEPRECATED front matter 'disable%s' found, use '%s' or '%s.force' instead and invert the value; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-0-0" $filepath .name (lower .name) (lower .name) }}
|
||||
{{- else if and (eq .name "Math") (ne (index $.Params "disableMathJax") nil) }}
|
||||
{{- $wantsPage = not (index $.Params "disableMathJax") }}
|
||||
{{- warnf "%q: DEPRECATED front matter 'disableMathJax' found, use 'math' or 'math.force' instead and invert the value; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-0-0" $filepath }}
|
||||
{{- end }}
|
||||
{{- with index $.Params $enable }}
|
||||
{{- $wantsPage = or
|
||||
(and (reflect.IsMap .) (eq (index . "force") true))
|
||||
(and (not (reflect.IsMap .)) (eq . true))
|
||||
}}
|
||||
{{- end }}
|
||||
|
||||
{{- $wantsSite := false }}
|
||||
{{- if ne (index $.Site.Params $disable) nil }}
|
||||
{{- $wantsSite = not (index $.Site.Params $disable) }}
|
||||
{{- warnf "DEPRECATED option 'disable%s' found, use '%s' or '%s.force' instead and invert the value; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-0-0" .name (lower .name) (lower .name) }}
|
||||
{{- else if and (eq .name "Math") (ne (index $.Site.Params "disableMathJax") nil) }}
|
||||
{{- $wantsSite = not (index $.Site.Params "disableMathJax") }}
|
||||
{{- warnf "DEPRECATED option 'disableMathJax' found, use 'math' or 'math.force' instead and invert the value; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-0-0" }}
|
||||
{{- end }}
|
||||
{{- with index $.Site.Params $enable }}
|
||||
{{- $wantsSite = or
|
||||
(and (reflect.IsMap .) (eq (index . "force") true))
|
||||
(and (not (reflect.IsMap .)) (eq . true))
|
||||
}}
|
||||
{{- end }}
|
||||
|
||||
{{- if or $wantsPage $wantsSite }}
|
||||
{{- $.Store.Set $has true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1 @@
|
||||
{{- return fileExists . }}
|
||||
@@ -0,0 +1,79 @@
|
||||
{{- $attributes := .attributes | default dict }}
|
||||
{{- $height := "auto" }}
|
||||
{{- $width := "auto" }}
|
||||
{{- $effects := dict "border" false "dataurl" false "inlinecontent" false "lazy" true "lightbox" true "shadow" false }}
|
||||
{{- if .page.Site.Params.imageeffects }}
|
||||
{{- $effects = merge $effects .page.Site.Params.imageeffects }}
|
||||
{{- end }}
|
||||
{{- if .page.Params.imageEffects }}
|
||||
{{- $effects = merge $effects .page.Params.imageEffects }}
|
||||
{{- end }}
|
||||
{{- $u := urls.Parse .url }}
|
||||
{{- if $u.RawQuery }}
|
||||
{{- if $u.Query.Has "classes" }}
|
||||
{{- $classes := slice | append (split ($u.Query.Get "classes") ",") }}
|
||||
{{- range $classes }}
|
||||
{{- $k := . }}
|
||||
{{- $v := true }}
|
||||
{{- if strings.HasPrefix $k "no" }}
|
||||
{{- $k := strings.TrimPrefix "no" $k }}
|
||||
{{- $v := false }}
|
||||
{{- end }}
|
||||
{{- $effects = merge $effects (dict $k $v) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $u.Query.Has "featherlight" }}
|
||||
{{- $filepath := "[virtual file]" }}{{ with and .page .page.File .page.File.Filename }}{{ $filepath = . }}{{ end }}
|
||||
{{- warnf "%q: DEPRECATED usage of 'featherlight' image CSS class found, use 'lightbox' instead; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-11-0" $filepath }}
|
||||
{{- $effects = merge $effects (dict "lightbox" (ne ($u.Query.Get "featherlight") "false")) }}
|
||||
{{- end }}
|
||||
{{- range $k, $v := $effects }}
|
||||
{{- if $u.Query.Has $k }}
|
||||
{{- $effects = merge $effects (dict $k (ne ($u.Query.Get $k) "false")) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $k, $v := $effects }}
|
||||
{{- if $u.Query.Has $k }}
|
||||
{{- $paramValue := $u.Query.Get $k }}
|
||||
{{- $newValue := true }}
|
||||
{{- if eq $paramValue "" }}
|
||||
{{- $newValue = true }}
|
||||
{{- else if eq $paramValue "true" }}
|
||||
{{- $newValue = true }}
|
||||
{{- else if eq $paramValue "false" }}
|
||||
{{- $newValue = false }}
|
||||
{{- else }}
|
||||
{{- $newValue = $paramValue }}
|
||||
{{- end }}
|
||||
{{- $effects = merge $effects (dict $k $newValue) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with $u.Query.Get "height" }}
|
||||
{{- $height = . }}
|
||||
{{- end }}
|
||||
{{- with $u.Query.Get "width" }}
|
||||
{{- $width = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $classes := slice }}
|
||||
{{- range $k, $v := $effects }}
|
||||
{{- if $v }}
|
||||
{{- if eq (printf "%T" $v) "bool" }}
|
||||
{{- $classes = $classes | append $k }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .linkObject $effects.inlinecontent (eq .linkObject.MediaType.Type "image/svg+xml") }}
|
||||
{{- $content := .linkObject.Content | replaceRE `(?s)^\s*<\?.*?\?>\s*` "" }}
|
||||
{{- $attributes = merge $attributes (dict "content" $content) }}
|
||||
{{- else if and .linkObject $effects.dataurl }}
|
||||
{{- $src := printf "data:%s;base64,%s" .linkObject.MediaType.Type (.linkObject.Content | base64Encode) }}
|
||||
{{- $attributes = merge $attributes (dict "src" $src) }}
|
||||
{{- else }}
|
||||
{{- $attributes = merge $attributes (dict "src" .url) }}
|
||||
{{- end }}
|
||||
{{- if $attributes.class }}{{ $classes = $classes | append (split $attributes.class " ") }}{{ end }}
|
||||
{{- $attributes = merge $attributes (dict "class" (delimit $classes " ")) }}
|
||||
{{- $attributes = merge $attributes (dict "style" (printf " height: %s; width: %s;%s" $height $width (index $attributes "style" | default ""))) }}
|
||||
{{- if $effects.lazy }}{{ $attributes = merge $attributes (dict "loading" "lazy") }}{{ end }}
|
||||
{{- return $attributes }}
|
||||
@@ -0,0 +1,72 @@
|
||||
{{- $attributes := .attributes | default dict }}
|
||||
{{- /* target will be boolean false if no user defined value was set and effect default should be applied */}}
|
||||
{{- $target := false }}
|
||||
{{- $u := urls.Parse .url }}
|
||||
{{- if $u.IsAbs }}
|
||||
{{- $attributes = merge $attributes (dict "rel" "external") }}
|
||||
{{- $target = "_blank" }}
|
||||
{{- if isset .page.Site.Params "externallinktarget" }}
|
||||
{{- $target = .page.Site.Params.externalLinkTarget }}
|
||||
{{- if in (slice "false" false 0) $target }}
|
||||
{{- $target = "" }}
|
||||
{{- end }}
|
||||
{{- if in (slice "true" true 1) $target }}
|
||||
{{- $target = "_blank" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $effects := dict "download" false "target" false }}
|
||||
{{- if .page.Site.Params.linkeffects }}
|
||||
{{- $effects = merge $effects .page.Site.Params.linkeffects }}
|
||||
{{- end }}
|
||||
{{- if .page.Params.linkeffects }}
|
||||
{{- $effects = merge $effects .page.Params.linkeffects }}
|
||||
{{- end }}
|
||||
{{- $target := .target | default $target }}
|
||||
{{- if ne (printf "%T" $target) "bool" }}
|
||||
{{- $effects = merge $effects (dict "target" $target) }}
|
||||
{{- end }}
|
||||
{{- if $u.RawQuery }}
|
||||
{{- if $u.Query.Has "classes" }}
|
||||
{{- $classes := slice | append (split ($u.Query.Get "classes") ",") }}
|
||||
{{- range $classes }}
|
||||
{{- $k := . }}
|
||||
{{- $v := true }}
|
||||
{{- if strings.HasPrefix $k "no" }}
|
||||
{{- $k := strings.TrimPrefix "no" $k }}
|
||||
{{- $v := false }}
|
||||
{{- end }}
|
||||
{{- $effects = merge $effects (dict $k $v) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $k, $v := $effects }}
|
||||
{{- if $u.Query.Has $k }}
|
||||
{{- $paramValue := $u.Query.Get $k }}
|
||||
{{- $newValue := true }}
|
||||
{{- if eq $paramValue "" }}
|
||||
{{- $newValue = true }}
|
||||
{{- else if eq $paramValue "true" }}
|
||||
{{- $newValue = true }}
|
||||
{{- else if eq $paramValue "false" }}
|
||||
{{- $newValue = false }}
|
||||
{{- else }}
|
||||
{{- $newValue = $paramValue }}
|
||||
{{- end }}
|
||||
{{- $effects = merge $effects (dict $k $newValue) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $classes := slice }}
|
||||
{{- range $k, $v := $effects }}
|
||||
{{- if $v }}
|
||||
{{- if eq (printf "%T" $v) "bool" }}
|
||||
{{- $classes = $classes | append $k }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $attributes.class }}{{ $classes = $classes | append (split $attributes.class " ") }}{{ end }}
|
||||
{{- $attributes = merge $attributes (dict "class" (delimit $classes " ")) }}
|
||||
{{- $attributes = merge $attributes (dict "href" .url) }}
|
||||
{{- $attributes = merge $attributes (dict "download" $effects.download) }}
|
||||
{{- $attributes = merge $attributes (dict "target" $effects.target) }}
|
||||
{{- return $attributes }}
|
||||
@@ -0,0 +1,48 @@
|
||||
{{- $page := .page }}
|
||||
{{- $linkObject := "" }}
|
||||
{{- $u := urls.Parse .url }}
|
||||
{{- $path := strings.TrimPrefix "./" $u.Path }}
|
||||
{{- $searchLocal := .searchLocal | default true }}
|
||||
{{- $searchGlobal := .searchGlobal | default true }}
|
||||
{{- $searchPage := .searchPage | default true }}
|
||||
{{- $searchResource := .searchResource | default true }}
|
||||
{{- if $path }}
|
||||
{{- with or
|
||||
(and $searchLocal $searchPage ($page.Page.GetPage $path))
|
||||
(and $searchLocal $searchPage ($page.Page.GetPage (strings.TrimRight "/" $path)))
|
||||
(and $searchGlobal $searchPage (site.GetPage $path))
|
||||
(and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path)))
|
||||
(and $searchLocal $searchResource ($page.Page.Resources.Get $path))
|
||||
(and $searchGlobal $searchResource (resources.Get $path))
|
||||
}}
|
||||
{{- $linkObject = . }}
|
||||
{{- else }}
|
||||
{{- /* is it a link into another translation? */}}
|
||||
{{- if strings.HasPrefix $path "/" }}
|
||||
{{- range $page.AllTranslations }}
|
||||
{{- $lang := .Language.Lang }}
|
||||
{{- $prefix := printf "/%s" $lang }}
|
||||
{{- $suffix := strings.TrimPrefix $prefix $path | default "/" }}
|
||||
{{- /* with the second check we check if the prefix was finished;
|
||||
eg. /pir/index.html vs. /pirate/index.html, were the latter is
|
||||
an external address outside of this site */}}
|
||||
{{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }}
|
||||
{{- with or
|
||||
(and $searchLocal $searchPage (.GetPage $suffix))
|
||||
(and $searchLocal $searchPage (.GetPage (strings.TrimRight "/" $suffix)))
|
||||
(and $searchGlobal $searchPage (site.GetPage $path))
|
||||
(and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path)))
|
||||
(and $searchLocal $searchResource (.Resources.Get $suffix))
|
||||
(and $searchGlobal $searchResource (resources.Get $suffix))
|
||||
}}
|
||||
{{- $linkObject = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $linkObject = $page.Page }}
|
||||
{{- end }}
|
||||
{{- return $linkObject }}
|
||||
@@ -0,0 +1,13 @@
|
||||
{{- $page := . }}
|
||||
{{- if (ne $page.Site.Params.disableRandomIds true) }}
|
||||
{{- $random := "" }}
|
||||
{{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }}
|
||||
{{- range (seq 16) }}
|
||||
{{- with ($set | shuffle | first 1) }}
|
||||
{{- $random = printf "%s%s" $random . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- md5 $random }}
|
||||
{{- else }}
|
||||
{{- printf "00000000000000000000000000000000" }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,5 @@
|
||||
{{- $linkObject := "" }}
|
||||
{{- with and . .menu }}
|
||||
{{- $linkObject = partial "_relearn/refObject.gotmpl" (dict "page" $.page "objectRef" .PageRef "refObject" .Page "searchPage" $.searchPage "searchResource" $.searchResource) }}
|
||||
{{- end }}
|
||||
{{- return $linkObject }}
|
||||
@@ -0,0 +1,25 @@
|
||||
{{- $url := "" }}
|
||||
{{- /* because Hugo can not resolve a pageRef if it contains URL query params or
|
||||
fragments, we simply don't access the .Page here */}}
|
||||
{{- with and . .menu }}
|
||||
{{- if .PageRef }}
|
||||
{{- $url = .PageRef }}
|
||||
{{- $linkObject := partial "_relearn/refObject.gotmpl" (dict "page" $.page "objectRef" .PageRef "refObject" .Page) }}
|
||||
{{- if $linkObject }}
|
||||
{{- $url = partial "_relearn/decoratedLink.gotmpl" (dict "url" .PageRef "page" $.page "linkObject" $linkObject "param" "link" "hideFilepath" true) }}
|
||||
{{- else }}
|
||||
{{- $msg := printf "config option 'pageRef' %q for 'menu' entry %q is not a page or a resource" .PageRef (or .KeyName .Identifier .Name .Title) }}
|
||||
{{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" .PageRef "page" $.page "param" "link" "msg" $msg) }}
|
||||
{{- end }}
|
||||
{{- else if .URL }}
|
||||
{{- $url = .URL | relLangURL }}
|
||||
{{- $u := urls.Parse $url }}
|
||||
{{- if $u.IsAbs }}
|
||||
{{- partialCached "_relearn/urlExists.gotmpl" (dict "url" $url "page" $.page "type" "menu link") $u.String }}
|
||||
{{- else }}
|
||||
{{- $msg := printf "config option 'url' %q for 'menu' entry %q is a local URL; if it references a page or a resource use 'pageRef' instead" .URL (or .KeyName .Identifier .Name .Title) }}
|
||||
{{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" .URL "page" $.page "param" "link" "msg" $msg) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $url }}
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- $title := "" }}
|
||||
{{- with and . .menu }}
|
||||
{{- $objectTitle := "" }}
|
||||
{{- $menuPage := partial "_relearn/menuObject.gotmpl" (dict "page" $.page "menu" . "searchResource" false) }}
|
||||
{{- with $menuPage }}
|
||||
{{- $objectTitle = or .LinkTitle .Title }}
|
||||
{{- else }}
|
||||
{{- $menuResource := partial "_relearn/menuObject.gotmpl" (dict "page" $.page "menu" . "searchPage" false) }}
|
||||
{{- with $menuResource }}
|
||||
{{- $objectTitle = .Title }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $title = or .Title (.Name | safeHTML) (.Identifier | safeHTML) }}
|
||||
{{- if and (eq $objectTitle .Title) (ne .Name .Title) }}
|
||||
{{- $title = (.Name | safeHTML) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $title }}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{- /* https://discourse.gohugo.io/t/how-to-know-the-section-depth/37302/4 */ -}}
|
||||
{{- $page := .page }}
|
||||
{{- $depth := .depth | default 0 }}
|
||||
{{- with $page.Parent }}
|
||||
{{- $depth = add $depth 1 }}
|
||||
{{- partial "_relearn/pageDepth.gotmpl" (dict "page" . "depth" $depth) }}
|
||||
{{- else }}
|
||||
{{- $depth }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,4 @@
|
||||
{{- return or
|
||||
.Params.hidden
|
||||
(and .RelPermalink (not (or .Title (partial "title.gotmpl" (dict "page" . "linkTitle" true)))))
|
||||
}}
|
||||
@@ -0,0 +1,16 @@
|
||||
{{- $ret := false }}
|
||||
{{- with .page }}
|
||||
{{- $ret = partialCached "_relearn/pageIsHidden.gotmpl" . .Path }}
|
||||
{{- if not $ret }}
|
||||
{{- with .Parent }}
|
||||
{{- if eq . $.to }}
|
||||
{{- /* stop if we reach the top */}}
|
||||
{{- else if partialCached "_relearn/pageIsHidden.gotmpl" . .Path }}
|
||||
{{- $ret = true }}
|
||||
{{- else }}
|
||||
{{- $ret = partialCached "_relearn/pageIsHiddenSelfOrAncestor.gotmpl" (dict "page" . "to" $.to) .Path $.to.Path }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $ret }}
|
||||
@@ -0,0 +1,5 @@
|
||||
{{- $ret := false }}
|
||||
{{- if hasPrefix .Path "/_relearn" }}
|
||||
{{- $ret = true }}
|
||||
{{- end }}
|
||||
{{- return $ret }}
|
||||
@@ -0,0 +1,132 @@
|
||||
{{- $next := "" }}
|
||||
{{- if eq .Page.Kind "term" }}
|
||||
{{- /* go to next term page */}}
|
||||
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" $taxonomy_page $taxonomy_page.Path }}
|
||||
{{- $next = partial "inline/next-term" (dict "collection" $pages "item" .) }}
|
||||
{{- else if eq .Page.Kind "taxonomy" }}
|
||||
{{- /* go to first term page */}}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" . .Path }}
|
||||
{{- with index $pages 0 }}
|
||||
{{- $next = .Page }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $next = partial "inline/next-page" . }}
|
||||
{{- end }}
|
||||
{{- return $next }}
|
||||
|
||||
{{- define "partials/inline/next-term" }}
|
||||
{{- $collection := .collection }}
|
||||
{{- $item := .item }}
|
||||
{{- $found := false }}
|
||||
{{- $result := "" }}
|
||||
{{- range $collection }}
|
||||
{{- if $found }}
|
||||
{{- $result = .Page.Page }}
|
||||
{{- break }}
|
||||
{{- else if eq $item .Page.Page }}
|
||||
{{- $found = true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $result }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/next-page" }}
|
||||
{{- $nextVisible := "" }}
|
||||
{{- $currentNode := . }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $currentNode) $currentNode.Path }}
|
||||
{{- range $pages }}
|
||||
{{- $nextVisible = partial "inline/leftmost_descendant" . }}
|
||||
{{- if $nextVisible }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not $nextVisible }}
|
||||
{{- $nextVisible = partial "inline/next_sibling_or_ancestor" $currentNode }}
|
||||
{{- end }}
|
||||
{{- return $nextVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/next_sibling_or_ancestor" }}
|
||||
{{- $currentNode := . }}
|
||||
{{- $nextSibling := "" }}
|
||||
{{- with partial "inline/parent" $currentNode }}
|
||||
{{- $parent := . }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $parent) $parent.Path }}
|
||||
{{- $nextVisible := partial "inline/next_sibling" (dict "siblings" $pages "currentNode" $currentNode) }}
|
||||
{{- range $pages }}
|
||||
{{- if not $nextVisible }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- $nextSibling = partial "inline/leftmost_descendant" $nextVisible }}
|
||||
{{- if $nextSibling }}
|
||||
{{- break }}
|
||||
{{- else }}
|
||||
{{- $nextVisible = partial "inline/next_sibling" (dict "siblings" $pages "currentNode" $nextVisible) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not $nextSibling }}
|
||||
{{- if $nextVisible }}
|
||||
{{- $nextSibling = partial "inline/leftmost_descendant" $nextVisible }}
|
||||
{{- end }}
|
||||
{{- if not $nextSibling }}
|
||||
{{- $nextSibling = partial "inline/next_sibling_or_ancestor" $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nextSibling }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/next_sibling" }}
|
||||
{{- $siblings := .siblings }}
|
||||
{{- $currentNode := .currentNode }}
|
||||
{{- $nextSibling := "" }}
|
||||
{{- $currentFound := false }}
|
||||
{{- range $siblings }}
|
||||
{{- if eq . $currentNode }}
|
||||
{{- $currentFound = true }}
|
||||
{{- else if and $currentFound (not (or (eq .Title "") .Params.hidden .Params.menuUrl .Params.menuPageRef)) }}
|
||||
{{- $nextSibling = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nextSibling }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/leftmost_descendant" }}
|
||||
{{- $leftmostVisible := "" }}
|
||||
{{- if not (or (eq .Title "") .Params.hidden .Params.menuUrl .Params.menuPageRef) }}
|
||||
{{- if .RelPermalink }}
|
||||
{{- $leftmostVisible = . }}
|
||||
{{- else }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
||||
{{- range $pages }}
|
||||
{{- with partial "inline/leftmost_descendant" . }}
|
||||
{{- $leftmostVisible = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $leftmostVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/parent" }}
|
||||
{{- $nonheadless := "" }}
|
||||
{{- $page := . }}
|
||||
{{- $parent := .Parent }}
|
||||
{{- if not (partial "_relearn/pageIsSpecial.gotmpl" $page) }}
|
||||
{{- with $parent }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
||||
{{- range $pages }}
|
||||
{{- if eq . $page }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nonheadless }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,106 @@
|
||||
{{- $prev := "" }}
|
||||
{{- if eq .Page.Kind "term" }}
|
||||
{{- /* go to previous term page or taxonomy page if it is the first term */}}
|
||||
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" $taxonomy_page $taxonomy_page.Path }}
|
||||
{{- $prev = partial "inline/prev-term" (dict "collection" $pages "item" .) | default $taxonomy_page }}
|
||||
{{- else if eq .Page.Kind "taxonomy" }}
|
||||
{{- $prev = .Site.Home }}
|
||||
{{- else if eq .Page.Kind "home" }}
|
||||
{{- /* no prev here */}}
|
||||
{{- else }}
|
||||
{{- $prev = or (partial "inline/prev_page" .) .Site.Home }}
|
||||
{{- end }}
|
||||
{{- return $prev }}
|
||||
|
||||
{{- define "partials/inline/prev-term" }}
|
||||
{{- $collection := .collection }}
|
||||
{{- $item := .item }}
|
||||
{{- $last := "" }}
|
||||
{{- $result := "" }}
|
||||
{{- range $collection }}
|
||||
{{- if eq $item .Page.Page }}
|
||||
{{- $result = $last }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- $last = .Page.Page }}
|
||||
{{- end }}
|
||||
{{- return $result }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/prev_page" }}
|
||||
{{- $previousVisible := "" }}
|
||||
{{- $currentNode := . }}
|
||||
{{- with partial "inline/parent" $currentNode }}
|
||||
{{- $parent := . }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $parent) $parent.Path }}
|
||||
{{- $previousSibling := partial "inline/prev_sibling" (dict "siblings" $pages "currentNode" $currentNode) }}
|
||||
{{- if $previousSibling }}
|
||||
{{- $previousVisible = partial "inline/rightmost_descendant" $previousSibling }}
|
||||
{{- if not $previousVisible }}
|
||||
{{- if $previousSibling.RelPermalink }}
|
||||
{{- $previousVisible = $previousSibling }}
|
||||
{{- else }}
|
||||
{{- $previousVisible = partial "inline/prev_page" $previousSibling }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if $parent.RelPermalink }}
|
||||
{{- $previousVisible = $parent }}
|
||||
{{- else }}
|
||||
{{- $previousVisible = partial "inline/prev_page" $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $previousVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/prev_sibling" }}
|
||||
{{- $previousSibling := "" }}
|
||||
{{- $siblings := .siblings }}
|
||||
{{- $currentNode := .currentNode }}
|
||||
{{- range $siblings }}
|
||||
{{- if eq . $currentNode }}
|
||||
{{- break }}
|
||||
{{- else if not (or (eq .Title "") .Params.hidden .Params.menuUrl .Params.menuPageRef) }}
|
||||
{{- $previousSibling = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $previousSibling }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/rightmost_descendant" }}
|
||||
{{- $rightmostVisible := . }}
|
||||
{{- $pages := (partialCached "_relearn/pages.gotmpl" (dict "page" $rightmostVisible) $rightmostVisible.Path) | collections.Reverse }}
|
||||
{{- range $pages }}
|
||||
{{- if not (or (eq .Title "") .Params.hidden .Params.menuUrl .Params.menuPageRef) }}
|
||||
{{- with partial "inline/rightmost_descendant" . }}
|
||||
{{- if .RelPermalink }}
|
||||
{{- $rightmostVisible = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $rightmostVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/parent" }}
|
||||
{{- $nonheadless := "" }}
|
||||
{{- $page := . }}
|
||||
{{- $parent := .Parent }}
|
||||
{{- if not (partial "_relearn/pageIsSpecial.gotmpl" $page) }}
|
||||
{{- with $parent }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
||||
{{- range $pages }}
|
||||
{{- if eq . $page }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nonheadless }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,40 @@
|
||||
{{- $page := .page }}
|
||||
{{- /* default sort order for the theme is historically by weight */}}
|
||||
{{- $by := .by }}
|
||||
{{- if eq $by "auto" }}
|
||||
{{- $by = "" }}
|
||||
{{- end }}
|
||||
{{- $by = $by | default $page.Params.ordersectionsby | default $page.Site.Params.ordersectionsby | default "weight" }}
|
||||
|
||||
{{- $pages := slice }}
|
||||
|
||||
{{- if eq $by "weight" }}
|
||||
{{- $pages = $page.Pages.ByWeight }}
|
||||
{{- else if or (eq $by "name") (eq $by "title") (eq $by "linktitle") }}
|
||||
{{- $pages = $page.Pages.ByLinkTitle }}
|
||||
{{- else if eq $by "modifieddate" }}
|
||||
{{- $pages = $page.Pages.Lastmod }}
|
||||
{{- else if eq $by "expirydate" }}
|
||||
{{- $pages = $page.Pages.ByExpiryDate }}
|
||||
{{- else if eq $by "publishdate" }}
|
||||
{{- $pages = $page.Pages.ByPublishDate }}
|
||||
{{- else if eq $by "date" }}
|
||||
{{- $pages = $page.Pages.ByDate }}
|
||||
{{- else if eq $by "length" }}
|
||||
{{- $pages = $page.Pages.ByLength }}
|
||||
{{- else if eq $by "default" }}
|
||||
{{- $pages = $page.Pages }}
|
||||
{{- else }}
|
||||
{{- $filepath := "[virtual file]" }}{{ with and $page $page.File $page.File.Filename }}{{ $filepath = . }}{{ end }}
|
||||
{{- warnf "%q: Unknown pages sort order '%s'" $filepath }}
|
||||
{{- $pages = $page.Pages }}
|
||||
{{- end }}
|
||||
|
||||
{{- $filtered_pages := slice }}
|
||||
{{- range $pages }}
|
||||
{{- if not (partial "_relearn/pageIsSpecial.gotmpl" .) }}
|
||||
{{- $filtered_pages = $filtered_pages | append . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- return $filtered_pages }}
|
||||
@@ -0,0 +1,15 @@
|
||||
{{- $pages := slice }}
|
||||
{{- range .Data.Terms }}
|
||||
{{- $count := 0 }}
|
||||
{{- range .Pages }}
|
||||
{{- /* count pages of term */}}
|
||||
{{- if and .Title .RelPermalink (or (ne .Site.Params.disableTagHiddenPages true) (not (partialCached "_relearn/pageIsHiddenSelfOrAncestor.gotmpl" (dict "page" . "to" .Site.Home) .Path .Site.Home.Path) ) ) }}
|
||||
{{- $count = add $count 1 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $count }}
|
||||
{{- $pages = $pages| append (dict "Title" (partial "title.gotmpl" (dict "page" .Page "linkTitle" true)) "Page" .Page "Count" $count )}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $pages = sort $pages ".Title" }}
|
||||
{{- return $pages }}
|
||||
@@ -0,0 +1,8 @@
|
||||
{{- $pages := slice }}
|
||||
{{- range .Pages }}
|
||||
{{- if and .Title .RelPermalink (or (ne .Site.Params.disableTagHiddenPages true) (not (partialCached "_relearn/pageIsHiddenSelfOrAncestor.gotmpl" (dict "page" . "to" .Site.Home) .Path .Site.Home.Path) ) ) }}
|
||||
{{- $pages = $pages | append (dict "Title" .Title "Page" . )}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $pages = sort $pages ".Title" }}
|
||||
{{- return $pages }}
|
||||
@@ -0,0 +1,11 @@
|
||||
{{- $linkObject := "" }}
|
||||
{{- /* because Hugo can not resolve a pageRef if it contains URL query params or
|
||||
fragments, we do it ourself if we detect such a case */}}
|
||||
{{- with .refObject }}
|
||||
{{- $linkObject = . }}
|
||||
{{- else }}
|
||||
{{- with .objectRef }}
|
||||
{{- $linkObject = partial "_relearn/linkObject.gotmpl" (dict "url" . "page" $.page "searchLocal" false "searchPage" $.searchPage "searchResource" $.searchResource) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $linkObject }}
|
||||
@@ -0,0 +1,11 @@
|
||||
{{- /* generates an uphill path from the current page to the root of the site */}}
|
||||
{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }}
|
||||
{{- $relBasePath := .RelPermalink }}
|
||||
{{- $relBasePath = replaceRE "/[^/]*$" "" $relBasePath }}
|
||||
{{- $relBasePath = strings.TrimPrefix $subdir $relBasePath }}
|
||||
{{- $relBasePath = replaceRE "/[^/]*" "/.." $relBasePath }}
|
||||
{{- $relBasePath = trim $relBasePath "/" }}
|
||||
{{- if not $relBasePath }}
|
||||
{{- $relBasePath = "." }}
|
||||
{{- end }}
|
||||
{{- return $relBasePath }}
|
||||
@@ -0,0 +1,10 @@
|
||||
{{- /* generates an uphill path from the current page to the root of the server */}}
|
||||
{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }}
|
||||
{{- $relBaseUri := .RelPermalink }}
|
||||
{{- $relBaseUri = replaceRE "/[^/]*$" "" $relBaseUri }}
|
||||
{{- $relBaseUri = replaceRE "/[^/]*" "/.." $relBaseUri }}
|
||||
{{- $relBaseUri = trim $relBaseUri "/" }}
|
||||
{{- if not $relBaseUri }}
|
||||
{{- $relBaseUri = "." }}
|
||||
{{- end }}
|
||||
{{- return $relBaseUri }}
|
||||
@@ -0,0 +1,260 @@
|
||||
{{- $page := . }}
|
||||
{{- $nonautothemevariants := slice }}
|
||||
{{- $formathtmlpre := ":root:not([data-r-output-format='print']):not([data-r-theme-variant='my-custom-variant'])" }}
|
||||
{{- $formathtml := "" }}
|
||||
{{- $minify := not hugo.IsServer }}
|
||||
{{- if and (isset site.Params "minify") (ne site.Params.minify "") }}
|
||||
{{- $minify = site.Params.minify }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Unification run:
|
||||
- convert from old forms to slice of dicts
|
||||
- add default name property
|
||||
- convert auto property to slice
|
||||
- remember default variants for auto mode
|
||||
*/}}
|
||||
{{- $tempthemevariants := slice | append (.Site.Params.themeVariant | default "auto" ) }}
|
||||
{{- $themevariants := slice }}
|
||||
{{- range $tempthemevariant := $tempthemevariants }}
|
||||
{{- $themevariant := $tempthemevariant }}
|
||||
{{- if not (reflect.IsMap $themevariant) }}
|
||||
{{- $themevariant = dict "identifier" $tempthemevariant }}
|
||||
{{- end }}
|
||||
{{- if not $themevariant.name }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "name" ($themevariant.identifier | humanize | strings.Title)) }}
|
||||
{{- end }}
|
||||
{{- if eq $themevariant.identifier "auto" }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "auto" ($themevariant.auto | default slice)) }}
|
||||
{{- end }}
|
||||
{{- if not (isset $themevariant "auto") }}
|
||||
{{- $nonautothemevariants = $nonautothemevariants | append $themevariant.identifier }}
|
||||
{{- end }}
|
||||
{{- if eq $themevariant.identifier "my-custom-variant" }}
|
||||
{{- errorf "\"theme-%s.css\": the variant identifier '%s' is reserved for the theme's variant generator, instead rename it to something different" "my-custom-variant" "my-custom-variant" }}
|
||||
{{- end }}
|
||||
{{- $themevariants = $themevariants | append $themevariant }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Generator run:
|
||||
- fill up auto property with defaults
|
||||
- write variant & chroma CSS string of normal variants and for light and dark of auto variants
|
||||
*/}}
|
||||
{{- $defaultautothemevariants := slice }}
|
||||
{{- $defaultautothemevariants = $defaultautothemevariants | append (index .Site.Params.themeVariantAuto 0 | default (index $nonautothemevariants 0) | default "relearn-light") }}
|
||||
{{- $defaultautothemevariants = $defaultautothemevariants | append (index .Site.Params.themeVariantAuto 1 | default (index $nonautothemevariants 1) | default "relearn-dark") }}
|
||||
{{- $tempthemevariants = $themevariants }}
|
||||
{{- $themevariants = slice }}
|
||||
{{- range $tempthemevariant := $tempthemevariants }}
|
||||
{{- $themevariant := $tempthemevariant }}
|
||||
{{- if collections.IsSet $themevariant "auto" }}
|
||||
{{- $light := index $themevariant.auto 0 | default (index $defaultautothemevariants 0) }}
|
||||
{{- $dark := index $themevariant.auto 1 | default (index $defaultautothemevariants 1) }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "auto" (slice | append $light | append $dark)) }}
|
||||
{{- $lightthemevariant := partial "inline/get-theme-details" (dict "themevariant" $themevariant "identifier" $light) }}
|
||||
{{- $darkthemevariant := partial "inline/get-theme-details" (dict "themevariant" $themevariant "identifier" $dark) }}
|
||||
{{- $formathtmlpre = print $formathtmlpre
|
||||
":not([data-r-theme-variant='" $themevariant.identifier "'])"
|
||||
}}
|
||||
{{- $formathtml = print $formathtml
|
||||
"\n:root:not([data-r-output-format='print'])[data-r-theme-variant='" $themevariant.identifier "'] {"
|
||||
"\n@media screen and (prefers-color-scheme: light) {"
|
||||
"\n" $lightthemevariant.themecontent
|
||||
"\n" $lightthemevariant.chromacontent
|
||||
"\n}"
|
||||
"\n@media screen and (prefers-color-scheme: dark) {"
|
||||
"\n" $darkthemevariant.themecontent
|
||||
"\n" $darkthemevariant.chromacontent
|
||||
"\n}"
|
||||
"\n}"
|
||||
}}
|
||||
{{- else }}
|
||||
{{- $themevariant = partial "inline/get-theme-details" (dict "themevariant" $themevariant "identifier" $themevariant.identifier)}}
|
||||
{{- $formathtmlpre = print $formathtmlpre
|
||||
":not([data-r-theme-variant='" $themevariant.identifier "'])"
|
||||
}}
|
||||
{{- $formathtml = print $formathtml
|
||||
"\n:root:not([data-r-output-format='print'])[data-r-theme-variant='" $themevariant.identifier "'] {"
|
||||
"\n" $themevariant.themecontent
|
||||
"\n" $themevariant.chromacontent
|
||||
"\n}"
|
||||
}}
|
||||
{{- end }}
|
||||
{{- $themevariants = $themevariants | append $themevariant }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
- Read default stuff
|
||||
*/}}
|
||||
{{- $defaultthemevariant := partial "inline/get-theme-details" (dict "themevariant" (dict) "identifier" "relearn-light") }}
|
||||
{{- $nucleuscontent := "" }}
|
||||
{{- with resources.Get "css/nucleus.css" }}
|
||||
{{- $nucleuscontent = .Content }}
|
||||
{{- end }}
|
||||
{{- $fontscontent := "" }}
|
||||
{{- with resources.Get "css/fonts.css" }}
|
||||
{{- $fontscontent = .Content }}
|
||||
{{- end }}
|
||||
{{- $htmlcontent := "" }}
|
||||
{{- with resources.Get "css/format-html.css" }}
|
||||
{{- $htmlcontent = .Content }}
|
||||
{{- end }}
|
||||
{{- $printcontent := "" }}
|
||||
{{- with resources.Get "css/format-print.css" }}
|
||||
{{- $printcontent = .Content }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
- Read variables.css and add custom box styles
|
||||
*/}}
|
||||
{{- $variablescontent := "" }}
|
||||
{{- with resources.Get "css/variables.css" }}
|
||||
{{- $boxcontent := "" }}
|
||||
{{- range $page.Site.Params.boxStyle }}
|
||||
{{- $identifier := upper .identifier }}
|
||||
{{- $boxcontent = print $boxcontent
|
||||
"\n --INTERNAL-BOX-" $identifier "-color: var(--BOX-" $identifier "-color, " .color ");"
|
||||
"\n --INTERNAL-BOX-" $identifier "-TEXT-color: var(--BOX-" $identifier "-TEXT-color, var(--INTERNAL-BOX-TEXT-color));"
|
||||
}}
|
||||
{{- end }}
|
||||
{{- $variablescontent = print
|
||||
":root {"
|
||||
"\n" .Content
|
||||
$boxcontent
|
||||
"\n}"
|
||||
}}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
- Write theme.css
|
||||
*/}}
|
||||
{{- with resources.Get "css/theme.css" }}
|
||||
{{- $boxcontent := "" }}
|
||||
{{- range $page.Site.Params.boxStyle }}
|
||||
{{- $identifier := upper .identifier }}
|
||||
{{- $identifierl := lower .identifier }}
|
||||
{{- $boxcontent = print $boxcontent
|
||||
"\n.cstyle." $identifierl " {"
|
||||
"\n --VARIABLE-BOX-color: var(--INTERNAL-BOX-" $identifier "-color);"
|
||||
"\n --VARIABLE-BOX-TEXT-color: var(--INTERNAL-BOX-" $identifier "-TEXT-color);"
|
||||
"\n}\n"
|
||||
}}
|
||||
{{- end }}
|
||||
{{- $themecontent := print
|
||||
$variablescontent
|
||||
"\n\n" $nucleuscontent
|
||||
"\n" .Content
|
||||
$boxcontent
|
||||
"\n" $fontscontent
|
||||
}}
|
||||
{{- $cssres := $themecontent | resources.FromString "css/theme.css" }}
|
||||
{{- if $minify }}
|
||||
{{- $cssres = $cssres | minify }}
|
||||
{{- end }}
|
||||
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} -->
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
- Write swagger.css
|
||||
*/}}
|
||||
{{- with resources.Get "css/swagger.css" }}
|
||||
{{- $swaggercontent := print
|
||||
$variablescontent "\n"
|
||||
.Content "\n"
|
||||
$fontscontent "\n"
|
||||
}}
|
||||
{{- $cssres := $swaggercontent | resources.FromString "css/swagger.css" }}
|
||||
{{- if $minify }}
|
||||
{{- $cssres = $cssres | minify }}
|
||||
{{- end }}
|
||||
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} -->
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
- Write format-html.css
|
||||
*/}}
|
||||
{{- $htmlcontent = print
|
||||
"@media screen {"
|
||||
"\n" $formathtmlpre ","
|
||||
$formathtml
|
||||
"\n}"
|
||||
"\n@media print {"
|
||||
"\n" $defaultthemevariant.themecontent
|
||||
"\n" $defaultthemevariant.chromacontent
|
||||
"\n}"
|
||||
"\n@media print {"
|
||||
"\n" $printcontent
|
||||
"\n}"
|
||||
"\n" $htmlcontent
|
||||
}}
|
||||
{{- $cssres := $htmlcontent | resources.FromString "css/format-html.css" }}
|
||||
{{- if $minify }}
|
||||
{{- $cssres = $cssres | minify }}
|
||||
{{- end }}
|
||||
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} -->
|
||||
|
||||
{{- /*
|
||||
- Write format-print.css
|
||||
*/}}
|
||||
{{- $printcontent = print
|
||||
":root[data-r-output-format='print'] {"
|
||||
"\n" $defaultthemevariant.themecontent
|
||||
"\n" $defaultthemevariant.chromacontent
|
||||
"\n}"
|
||||
"\n" $printcontent
|
||||
}}
|
||||
{{- $cssres := $printcontent | resources.FromString "css/format-print.css" }}
|
||||
{{- if $minify }}
|
||||
{{- $cssres = $cssres | minify }}
|
||||
{{- end }}
|
||||
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} -->
|
||||
|
||||
{{- return $themevariants }}
|
||||
|
||||
{{- define "partials/inline/get-theme-details" }}
|
||||
{{- $themevariant := .themevariant }}
|
||||
{{- $identifier := .identifier }}
|
||||
{{- $themecontent := "" }}
|
||||
{{- with resources.Get (printf "css/theme-%s.css" $identifier) }}
|
||||
{{- $themecontent = replaceRE `([ \t]*)(:root)` "${1}&${2}" .Content }}
|
||||
{{- else }}
|
||||
{{- errorf "\"theme-%s.css\": file not found in \"assets/css\"; if you are migrating from a theme version older thant 6.0.0, you have to move it over from \"static/css\"" $identifier }}
|
||||
{{- end }}
|
||||
{{- $chroma := "" }}
|
||||
{{- $chromacontent := "" }}
|
||||
{{- range findRESubmatch `[ \t]*@import\s+[^$]*?chroma-([^.]*?)\.css` $themecontent }}
|
||||
{{- $chroma = index . 1 }}
|
||||
{{- errorf "\"theme-%s.css\": UNSUPPORTED use of @import for chroma stylesheet, instead use '--CODE-theme: %s;'; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/6/#6-0-0" $identifier $chroma }}
|
||||
{{- end }}
|
||||
{{- $tempthemecontent := $themecontent }}
|
||||
{{- range findRESubmatch `[ \t]*@import\s+[^$]*?theme-([^.]*?)\.css` $themecontent }}
|
||||
{{- $subidentifier := index . 1 }}
|
||||
{{- $themevariant = partial "inline/get-theme-details" (dict "themevariant" $themevariant "identifier" $subidentifier) }}
|
||||
{{- $tempthemecontent = replaceRE (printf `[ \t]*@import\s+[^$]*?theme-%s\.css["']?\s*\)?\s*;?` $subidentifier) $themevariant.themecontent $tempthemecontent 1 }}
|
||||
{{- $chroma = $themevariant.chroma }}
|
||||
{{- $chromacontent = $themevariant.chromacontent }}
|
||||
{{- end }}
|
||||
{{- $themecontent = replaceRE `(&\s*)+:root` "&:root" $tempthemecontent }}
|
||||
{{- range findRESubmatch `[ \t]*--CODE-theme\s*:\s*([^;]*?)\s*;` $themecontent }}
|
||||
{{- $chroma = index . 1 }}
|
||||
{{- $cssres := resources.Get (printf "css/chroma-%s.css" $chroma) }}
|
||||
{{- if not $cssres }}
|
||||
{{- errorf "\"chroma-%s.css\": file not found in \"assets/css\"; if you are migrating from a theme version older thant 6.0.0, you have to move it over from \"static/css\"" $chroma }}
|
||||
{{- end }}
|
||||
{{- $chromacontent = $cssres.Content }}
|
||||
{{- end }}
|
||||
{{- if not $chroma }}
|
||||
{{- $chroma = "relearn-light" }}
|
||||
{{- $cssres := resources.Get (printf "css/chroma-%s.css" $chroma) }}
|
||||
{{- if not $cssres }}
|
||||
{{- errorf "\"chroma-%s.css\": file not found in \"assets/css\"; if you are migrating from a theme version older thant 6.0.0, you have to move it over from \"static/css\"" $chroma }}
|
||||
{{- end }}
|
||||
{{- $chromacontent = $cssres.Content }}
|
||||
{{- $themecontent = replaceRE `(:root\s*\{[ \t]*)(\s*)` (printf "${1}${2}--CODE-theme: %s;${2}" $chroma) $themecontent }}
|
||||
{{- end }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "themecontent" $themecontent) }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "chroma" $chroma) }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "chromacontent" $chromacontent) }}
|
||||
{{- return $themevariant }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,23 @@
|
||||
{{- $pageParam := index .page.Params .param }}
|
||||
{{- $siteParam := index site.Params .param }}
|
||||
{{- $applyErrorIgnore := .applyErrorIgnore | default true }}
|
||||
{{- $errorlevel := or (and $pageParam $pageParam.errorlevel) (and $siteParam $siteParam.errorlevel) }}
|
||||
{{- $errorignore := slice | append (.page.Params.errorignore | default slice ) | append (site.Params.errorignore | default slice ) }}
|
||||
{{- if and (eq $errorlevel "warning") (partial "inline/show-error" (dict "errorignore" $errorignore "url" .url "applyErrorIgnore" $applyErrorIgnore)) }}
|
||||
{{- warnf .msg }}
|
||||
{{- else if and (eq $errorlevel "error") (partial "inline/show-error" (dict "errorignore" $errorignore "url" .url "applyErrorIgnore" $applyErrorIgnore)) }}
|
||||
{{- errorf .msg }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/show-error" }}
|
||||
{{- $ret := true }}
|
||||
{{- if .applyErrorIgnore }}
|
||||
{{- range .errorignore }}
|
||||
{{- if findRE . $.url 1 }}
|
||||
{{- $ret = false }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $ret }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user