refactor: move all template methods to proper GoHugo methods

Signed-off-by: Patrick Kollitsch <patrick@davids-neighbour.com>
This commit is contained in:
Patrick Kollitsch 2025-03-10 16:29:18 +07:00
parent 7a7de28a52
commit 180471112e
No known key found for this signature in database
GPG Key ID: 01A2661D61A772CA
32 changed files with 196 additions and 196 deletions

View File

@ -1,4 +1,4 @@
{{ define "header" }}{{ partial "page-header.html" . }}{{ end }}
{{ define "header" }}{{ partials.Include "page-header.html" . }}{{ end }}
{{ define "main" }}
<article class="center cf pv5 measure-wide-l">
<h1>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="{{ site.Language.LanguageCode }}" {{- with partialCached "func/GetLanguageDirection.html" "GetLanguageDirection" }} dir="{{ . }}" {{- end }}>
<html lang="{{ site.Language.LanguageCode }}" {{- with partials.IncludeCached "func/GetLanguageDirection.html" "GetLanguageDirection" }} dir="{{ . }}" {{- end }}>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -15,19 +15,19 @@
{{ else }}
<meta name="robots" content="noindex, nofollow">
{{ end }}
{{ with .Params.author | default .Site.Params.author }}
{{ with .Params.author | compare.Default .Site.Params.author }}
{{- $author := . -}}
{{- if reflect.IsSlice . -}}
{{- $author = delimit . ", " | plainify -}}
{{- $author = collections.Delimit . ", " | transform.Plainify -}}
{{- end -}}
<meta name="author" content="{{ $author }}">
{{ end }}
{{ partial "site-style.html" . }}
{{ partial "site-scripts.html" . }}
{{ partials.Include "site-style.html" . }}
{{ partials.Include "site-scripts.html" . }}
{{ block "favicon" . }}
{{ partialCached "site-favicon.html" . }}
{{ partials.IncludeCached "site-favicon.html" . }}
{{ end }}
{{ if .OutputFormats.Get "RSS" }}
@ -51,16 +51,16 @@
{{ if hugo.IsProduction }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ block "head" . }}{{ partial "head-additions.html" . }}{{ end }}
{{ block "head" . }}{{ partials.Include "head-additions.html" . }}{{ end }}
</head>
{{- $environment := hugo.Environment | default "production" -}}
<body class="ma0 {{ $.Param "body_classes" | default "avenir bg-near-white"}} {{ $environment }}">
{{- $environment := hugo.Environment | compare.Default "production" -}}
<body class="ma0 {{ $.Param "body_classes" | compare.Default "avenir bg-near-white"}} {{ $environment }}">
{{ block "header" . }}{{ partial "site-header.html" .}}{{ end }}
{{ block "header" . }}{{ partials.Include "site-header.html" .}}{{ end }}
<main class="pb7" role="main">
{{ block "main" . }}{{ end }}
</main>
{{ block "footer" . }}{{ partialCached "site-footer.html" . }}{{ end }}
{{ block "footer" . }}{{ partials.IncludeCached "site-footer.html" . }}{{ end }}
</body>
</html>

View File

@ -1,6 +1,6 @@
{{ define "main" }}
<article class="pa3 pa4-ns nested-copy-line-height">
<section class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | default "mid-gray" }}">
<section class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | compare.Default "mid-gray" }}">
{{- .Content -}}
</section>
<section class="flex-ns flex-wrap justify-around mt5">

View File

@ -1,12 +1,12 @@
{{ define "header" }}
{{/* We can override any block in the baseof file be defining it in the template */}}
{{ partial "page-header.html" . }}
{{ partials.Include "page-header.html" . }}
{{ end }}
{{ define "main" }}
{{ $page := .}}
{{ $section := .Site.GetPage "section" .Section }}
<article class="flex-l flex-wrap justify-between mw8 center ph3">
<article class="flex-wrap justify-between flex-l mw8 center ph3">
<header class="mt4 w-100">
<aside class="instapaper_ignoref b helvetica tracked ttu">
{{/*
@ -15,27 +15,27 @@
*/}}
{{ .CurrentSection.Title }}
</aside>
{{- partialCached "social/share.html" . . -}}
{{- partials.IncludeCached "social/share.html" . . -}}
<h1 class="f1 athelas mt3 mb1">
{{- .Title -}}
</h1>
{{ with .Params.author | default .Site.Params.author }}
{{ with .Params.author | compare.Default .Site.Params.author }}
<p class="tracked">
{{- if eq $page.Language "de" "en" "es" "fr" "it" "no" "pt" -}}
{{- i18n "by" -}}
{{- if compare.Eq $page.Language "de" "en" "es" "fr" "it" "no" "pt" -}}
{{- lang.Translate "by" -}}
{{ end -}} <strong>
{{- if reflect.IsSlice . -}}
{{ delimit . ", " | markdownify }}
{{ collections.Delimit . ", " | transform.Markdownify }}
{{- else -}}
{{ . | markdownify }}
{{ . | transform.Markdownify }}
{{- end -}}
</strong>
</p>
{{ end }}
{{/* Hugo uses Go's date formatting is set by example. Here are two formats */}}
{{ if not .Date.IsZero }}
<time class="f6 mv4 dib tracked" {{ printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safeHTMLAttr }}>
{{- .Date | time.Format (default "January 2, 2006" .Site.Params.date_format) -}}
<time class="f6 mv4 dib tracked" {{ fmt.Printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safe.HTMLAttr }}>
{{- .Date | time.Format (compare.Default "January 2, 2006" .Site.Params.date_format) -}}
</time>
{{end}}
@ -45,26 +45,26 @@
2) A section front matter value is set `show_reading_time = true`
3) A page front matter value is set `show_reading_time = true`
*/}}
{{ if (or (eq (.Param "show_reading_time") true) (eq $section.Params.show_reading_time true) )}}
<span class="f6 mv4 dib tracked"> - {{ i18n "readingTime" .ReadingTime }} </span>
<span class="f6 mv4 dib tracked"> - {{ i18n "wordCount" .WordCount }} </span>
{{ if (or (compare.Eq (.Param "show_reading_time") true) (compare.Eq $section.Params.show_reading_time true) )}}
<span class="f6 mv4 dib tracked"> - {{ lang.Translate "readingTime" .ReadingTime }} </span>
<span class="f6 mv4 dib tracked"> - {{ lang.Translate "wordCount" .WordCount }} </span>
{{ end }}
</header>
<div class="nested-copy-line-height lh-copy {{ $.Param "post_content_classes" | default "serif"}} f4 nested-links {{ $.Param "text_color" | default "mid-gray" }} {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl4-l" "pr4-l" }} w-two-thirds-l">
<div class="nested-copy-line-height lh-copy {{ $.Param "post_content_classes" | compare.Default "serif"}} f4 nested-links {{ $.Param "text_color" | compare.Default "mid-gray" }} {{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pl4-l" "pr4-l" }} w-two-thirds-l">
{{- .Content -}}
{{- partial "tags.html" . -}}
{{- partials.Include "tags.html" . -}}
<div class="mt6 instapaper_ignoref">
{{ if .Site.Config.Services.Disqus.Shortname }}
{{ template "_internal/disqus.html" . }}
{{ end }}
{{ if .Site.Params.commentoEnable }}
{{- partial "commento.html" . -}}
{{- partials.Include "commento.html" . -}}
{{ end }}
</div>
</div>
<aside class="w-30-l mt6-l">
{{- partial "menu-contextual.html" . -}}
{{- partials.Include "menu-contextual.html" . -}}
</aside>
</article>

View File

@ -1,16 +1,16 @@
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
{{ $featured_image := partials.Include "func/GetFeaturedImage.html" . }}
<article class="bb b--black-10">
<div class="db pv4 ph3 ph0-l no-underline dark-gray">
<div class="no-underline db pv4 ph3 ph0-l dark-gray">
<div class="flex flex-column flex-row-ns">
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
<div class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }} mb4 mb0-ns w-100 w-40-ns">
{{/* Trimming the slash and adding absURL make sure the image works no matter collections.Where our site lives */}}
<div class="{{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }} mb4 mb0-ns w-100 w-40-ns">
<a href="{{.RelPermalink}}" class="db grow">
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
</a>
</div>
{{ end }}
<div class="blah w-100{{ if $featured_image }} w-60-ns {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr3-ns" "pl3-ns" }}{{ end }}">
<div class="blah w-100{{ if $featured_image }} w-60-ns {{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pr3-ns" "pl3-ns" }}{{ end }}">
<h1 class="f3 fw1 athelas mt0 lh-title">
<a href="{{.RelPermalink}}" class="color-inherit dim link">
{{ .Title }}
@ -19,10 +19,10 @@
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
{{ with .Params.author | default .Site.Params.author }}
{{ with .Params.author | compare.Default .Site.Params.author }}
<p class="f6 lh-copy mv0">By {{ . }}</p>
{{- end -}}
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | compare.Default (lang.Translate "readMore") }}</a>
</div>
</div>
</div>

View File

@ -9,6 +9,6 @@
<div class="nested-links f5 lh-copy nested-copy-line-height">
{{ .Summary }}
</div>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | compare.Default (lang.Translate "readMore") }}</a>
</div>
</div>

View File

@ -1,7 +1,7 @@
{{ define "main" }}
<article class="cf pa3 pa4-m pa4-l">
<div class="measure-wide-l center f4 lh-copy nested-copy-line-height nested-links {{ $.Param "text_color" | default "mid-gray" }}">
<p>{{ i18n "taxonomyPageList" . }}</p>
<div class="measure-wide-l center f4 lh-copy nested-copy-line-height nested-links {{ $.Param "text_color" | compare.Default "mid-gray" }}">
<p>{{ lang.Translate "taxonomyPageList" . }}</p>
</div>
</article>
<div class="mw8 center">

View File

@ -1,7 +1,7 @@
{{ define "main" }}
{{ $data := .Data }}
<article class="cf pa3 pa4-m pa4-l">
<div class="measure-wide-l center f4 lh-copy nested-copy-line-height nested-links {{ $.Param "text_color" | default "mid-gray" }}">
<div class="measure-wide-l center f4 lh-copy nested-copy-line-height nested-links {{ $.Param "text_color" | compare.Default "mid-gray" }}">
{{ .Content }}
</div>
</article>
@ -10,7 +10,7 @@
{{ range $term := .Data.Pages }}
<h2 class="f1">
<a href="{{ $term.RelPermalink }}" class="link blue hover-black">
{{ $.Data.Singular | humanize }}: {{ $term.LinkTitle }}
{{ $.Data.Singular | inflect.Humanize }}: {{ $term.LinkTitle }}
</a>
</h2>
{{ range $term.Pages }}

View File

@ -1,33 +1,33 @@
{{ define "main" }}
<article class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | default "mid-gray" }}">
<article class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | compare.Default "mid-gray" }}">
{{ .Content }}
</article>
{{/* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. */}}
{{ $mainSections := site.Params.mainSections | default (slice "post") }}
{{ $mainSections := site.Params.mainSections | compare.Default (collections.Slice "post") }}
{{ $show_recent_posts := site.Params.ananke.show_recent_posts }}
{{ $section := where $.Site.RegularPages "Section" "in" $mainSections }}
{{ $section := collections.Where $.Site.RegularPages "Section" "in" $mainSections }}
{{ $section_count := len $section }}
{{ if and ($show_recent_posts) (ge $section_count 1) }}
{{ if and ($show_recent_posts) (compare.Ge $section_count 1) }}
<div class="pa3 pa4-ns w-100 w-70-ns center">
{{ $n_posts := $.Param "recent_posts_number" | default 3 }}
{{ $n_posts := $.Param "recent_posts_number" | compare.Default 3 }}
<section class="w-100 mw8">
{{/* Range through the first $n_posts items of the section */}}
{{ range (first $n_posts $section) }}
{{ range (collections.First $n_posts $section) }}
<div class="relative w-100 mb4">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
</section>
{{ if ge $section_count (add $n_posts 1) }}
{{ if compare.Ge $section_count (math.Add $n_posts 1) }}
<section class="w-100">
<h1 class="f3">{{ i18n "more" }}</h1>
<h1 class="f3">{{ lang.Translate "more" }}</h1>
{{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}}
{{ range (first 4 (after $n_posts $section)) }}
<h2 class="f5 fw4 mb4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "ml3" "mr3" }}">
{{ range (collections.First 4 (collections.After $n_posts $section)) }}
<h2 class="f5 fw4 mb4 dib {{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "ml3" "mr3" }}">
<a href="{{ .RelPermalink }}" class="link black dim">
{{ .Title }}
</a>

View File

@ -1,4 +1,4 @@
{{ define "header" }}{{ partial "page-header.html" . }}{{ end }}
{{ define "header" }}{{ partials.Include "page-header.html" . }}{{ end }}
{{ define "main" }}
<div class="flex-l mt2 mw8 center">
<article class="center cf pv5 ph3 ph4-ns mw7">
@ -7,7 +7,7 @@
{{ .Title }}
</h1>
</header>
<div class="nested-copy-line-height lh-copy f4 nested-links {{ $.Param "text_color" | default "mid-gray" }}">
<div class="nested-copy-line-height lh-copy f4 nested-links {{ $.Param "text_color" | compare.Default "mid-gray" }}">
{{ .Content }}
</div>
</article>

View File

@ -1,41 +1,41 @@
{{/*
GetFeaturedImage
This partial gets the url for featured image for a given page.
If a featured_image was set in the page's front matter, then that will be used.
If not set, this will search page resources to find an image that contains the word
"cover", and if found, returns the path to that resource.
If no featured_image was set, and there's no "cover" image in page resources, then
this partial returns an empty string (which evaluates to false).
@return RelPermalink to featured image, or an empty string if not found.
*/}}
{{/* Declare a new string variable, $linkToCover */}}
{{ $linkToCover := "" }}
{{ $matches := "feature,cover" }}
{{/* Use the value from front matter if present */}}
{{ with .Params.featured_image }}
{{/* This is the default case, the image lives in the static directory.
In which case we'll use the static dir */}}
{{ $linkToCover = trim . "/" | absURL }}
{{/* If we find a Page Resource matching the exact value, we use it instead. */}}
{{ with $.Resources.GetMatch . }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
{{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }}
{{ with .Resources.ByType "image" }}
{{ with .GetMatch (printf "**{%s}*" $matches) }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
{{/* return either a permalink, or an empty string. Note that partials can only have a single
return statement, so this needs to be at the end of the partial (and not in the if block) */}}
{{ return $linkToCover }}
{{/*
GetFeaturedImage
This partial gets the url for featured image for a given page.
If a featured_image was set in the page's front matter, then that will be used.
If not set, this will search page resources to find an image that contains the word
"cover", and if found, returns the path to that resource.
If no featured_image was set, and there's no "cover" image in page resources, then
this partial returns an empty string (which evaluates to false).
@return RelPermalink to featured image, or an empty string if not found.
*/}}
{{/* Declare a new string variable, $linkToCover */}}
{{ $linkToCover := "" }}
{{ $matches := "feature,cover" }}
{{/* Use the value from front matter if present */}}
{{ with .Params.featured_image }}
{{/* This is the default case, the image lives in the static directory.
In which case we'll use the static dir */}}
{{ $linkToCover = strings.Trim . "/" | urls.AbsURL }}
{{/* If we find a Page Resource matching the exact value, we use it instead. */}}
{{ with $.Resources.GetMatch . }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
{{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }}
{{ with .Resources.ByType "image" }}
{{ with .GetMatch (fmt.Printf "**{%s}*" $matches) }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
{{/* return either a permalink, or an empty string. Note that partials can only have a single
return statement, so this needs to be at the end of the partial (and not in the if block) */}}
{{ return $linkToCover }}

View File

@ -1,5 +1,5 @@
{{ $dir := "" }}
{{ if ge hugo.Version "0.67.1" }}
{{ if compare.Ge hugo.Version "0.67.1" }}
{{ with site.Language.LanguageDirection }}
{{ $dir = . }}
{{ end }}

View File

@ -14,11 +14,11 @@
{{ $main_style := dict }}
{{/* We prepare a slice of resources to be concatenated as one */}}
{{ $assets_to_concat := slice }}
{{ $assets_to_concat := collections.Slice }}
{{/* We add locale css files to the slice in the proper order */}}
{{ range slice "_tachyons.css" "_code.css" "_hugo-internal-templates.css" "_social-icons.css" "_styles.css" }}
{{ with partialCached "func/style/GetResource.html" . . }}
{{ $assets_to_concat = $assets_to_concat | append . }}
{{ range collections.Slice "_tachyons.css" "_code.css" "_hugo-internal-templates.css" "_social-icons.css" "_styles.css" }}
{{ with partials.IncludeCached "func/style/GetResource.html" . . }}
{{ $assets_to_concat = $assets_to_concat | collections.Append . }}
{{ end }}
{{ end }}
@ -26,20 +26,20 @@
{{- $networks := $config.follow.networks -}}
{{- $setups := (collections.Where $config.networks "slug" "in" $networks) }}
{{ with $setups }}
{{ $socials_rules := slice }}
{{ $socials_rules := collections.Slice }}
{{ range $service := . }}
{{ with .color }}
{{ $rule := printf `
{{ $rule := fmt.Printf `
.ananke-socials a.%s:hover {
color: %s !important;
}` $service.slug . }}
{{ $socials_rules = $socials_rules | append $rule }}
{{ $socials_rules = $socials_rules | collections.Append $rule }}
{{ end }}
{{ end }}
{{ with $socials_rules }}
{{ $socials_rules = delimit . " " }}
{{ $socials_rules = collections.Delimit . " " }}
{{ $socials_css := $socials_rules | resources.FromString "ananke/css/generated_socials.css" }}
{{ $assets_to_concat = $assets_to_concat | append $socials_css }}
{{ $assets_to_concat = $assets_to_concat | collections.Append $socials_css }}
{{ end }}
{{ end }}
@ -47,16 +47,16 @@
css asset directory we (unless condition below) add to aforementioned slice */}}
{{ with site.Params.custom_css }}
{{ range . }}
{{ with partialCached "func/style/GetResource.html" . . }}
{{ if eq .MediaType.SubType "x-scss" "x-sass" "scss" "sass" }}
{{ with partials.IncludeCached "func/style/GetResource.html" . . }}
{{ if compare.Eq .MediaType.SubType "x-scss" "x-sass" "scss" "sass" }}
{{ if hugo.IsExtended }}
{{/* as we cannot concatenate styles of different types, we sass/scss to be transformed to css beforehand */}}
{{ $assets_to_concat = $assets_to_concat | append (. | css.Sass) }}
{{ $assets_to_concat = $assets_to_concat | collections.Append (. | css.Sass) }}
{{ else }}
{{ partial "func/warn.html" (printf "Processing of stylesheet %s of type %s has been skipped. You need Hugo Extended to process such files." .Name .MediaType.SubType) }}
{{ partials.Include "func/warn.html" (fmt.Printf "Processing of stylesheet %s of type %s has been skipped. You need Hugo Extended to process such files." .Name .MediaType.SubType) }}
{{ end }}
{{ else }}
{{ $assets_to_concat = $assets_to_concat | append . }}
{{ $assets_to_concat = $assets_to_concat | collections.Append . }}
{{ end }}
{{ end }}
{{ end }}
@ -68,10 +68,10 @@ css asset directory we (unless condition below) add to aforementioned slice */}}
{{/* We then use toCSS to add sourceMap and minify */}}
{{ $options := dict "enableSourceMap" true "precision" 6 }}
{{ $style = $style | css.Sass $options | minify }}
{{ $style = $style | css.Sass $options | resources.Minify }}
{{/* We fingerprint in production for cache busting purposes */}}
{{ if hugo.IsProduction }}
{{ $style = $style | fingerprint }}
{{ $style = $style | resources.Fingerprint }}
{{ end }}
{{/* We're ready to set returning variable with resulting resource */}}
{{ $main_style = $style }}

View File

@ -12,7 +12,7 @@
*/}}
{{ $resource := dict }}
{{ with resources.Get (print "/ananke/css/" .) }}
{{ with resources.Get (fmt.Print "/ananke/css/" .) }}
{{ $resource = . }}
{{ end }}

View File

@ -9,7 +9,7 @@
@access private
@example - Go Template
{{ partial "func/warn.html" $message }}
{{ partials.Include "func/warn.html" $message }}
*/}}
{{ $header := "Ananke Theme Warning" }}
{{ warnf "\n%s:\n%s" $header . }}
{{ fmt.Warnf "\n%s:\n%s" $header . }}

View File

@ -1,8 +1,8 @@
{{ if .IsTranslated }}
<h4>{{ i18n "translations" }}</h4>
<ul class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr0 ml3" "pl0 mr3" }}">
<h4>{{ lang.Translate "translations" }}</h4>
<ul class="{{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pr0 ml3" "pl0 mr3" }}">
{{ range .Translations }}
<li class="list f5 f4-ns fw4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3" "pr3" }}">
<li class="list f5 f4-ns fw4 dib {{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pl3" "pr3" }}">
<a class="hover-white no-underline white-90" href="{{ .RelPermalink }}">{{ .Lang }}</a>
</li>
{{ end}}

View File

@ -5,7 +5,7 @@
{{- if .Params.toc -}}
<div class="bg-light-gray pa3 nested-list-reset nested-copy-line-height nested-links">
<p class="f5 b mb3">{{ i18n "whatsInThis" . }}</p>
<p class="f5 b mb3">{{ lang.Translate "whatsInThis" . }}</p>
{{ .TableOfContents }}
</div>
{{- end -}}
@ -15,11 +15,11 @@
https://gohugo.io/content-management/related/
*/}}
{{ $related := .Site.RegularPages.Related . | first 15 }}
{{ $related := .Site.RegularPages.Related . | collections.First 15 }}
{{ with $related }}
<div class="bg-light-gray pa3 nested-list-reset nested-copy-line-height nested-links">
<p class="f5 b mb3">{{ i18n "related" }}</p>
<p class="f5 b mb3">{{ lang.Translate "related" }}</p>
<ul class="pa0 list">
{{ range . }}
<li class="mb2">

View File

@ -1,2 +1,2 @@
{{ $new_window_icon_size := "8px" }}
<span class="new-window">{{ partial "svg/new-window.svg" (dict "size" $new_window_icon_size) }}</span>
<span class="new-window">{{ partials.Include "svg/new-window.svg" (dict "size" $new_window_icon_size) }}</span>

View File

@ -1,14 +1,14 @@
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
{{ $featured_image := partials.Include "func/GetFeaturedImage.html" . }}
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
{{ $featured_image_class := .Params.featured_image_class | default "cover bg-center" }}
{{ $cover_dimming_class := .Params.cover_dimming_class | default "bg-black-60" }}
{{ $featured_image_class := .Params.featured_image_class | compare.Default "cover bg-center" }}
{{ $cover_dimming_class := .Params.cover_dimming_class | compare.Default "bg-black-60" }}
<header class="{{ $featured_image_class }}" style="background-image: url('{{ $featured_image }}');">
<div class="{{ $cover_dimming_class }}">
{{ partial "site-navigation.html" . }}
{{ partials.Include "site-navigation.html" . }}
<div class="tc-l pv6 ph3 ph4-ns">
{{ if not .Params.omit_header_text }}
<div class="f2 f1-l fw2 white-90 mb0 lh-title">{{ .Title | default .Site.Title }}</div>
<div class="f2 f1-l fw2 white-90 mb0 lh-title">{{ .Title | compare.Default .Site.Title }}</div>
{{ with .Params.description }}
<div class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">
{{ . }}
@ -20,8 +20,8 @@
</header>
{{ else }}
<header>
<div class="{{ .Site.Params.background_color_class | default "bg-black" }}">
{{ partial "site-navigation.html" . }}
<div class="{{ .Site.Params.background_color_class | compare.Default "bg-black" }}">
{{ partials.Include "site-navigation.html" . }}
</div>
</header>
{{ end }}

View File

@ -1,3 +1,3 @@
{{ if .Site.Params.favicon }}
<link rel="shortcut icon" href="{{ relURL ($.Site.Params.favicon) }}" type="image/x-icon" />
<link rel="shortcut icon" href="{{ urls.RelURL ($.Site.Params.favicon) }}" type="image/x-icon" />
{{ end }}

View File

@ -1,8 +1,8 @@
<footer class="{{ .Site.Params.background_color_class | default "bg-black" }} bottom-0 w-100 pa3" role="contentinfo">
<footer class="{{ .Site.Params.background_color_class | compare.Default "bg-black" }} bottom-0 w-100 pa3" role="contentinfo">
<div class="flex justify-between">
<a class="f4 fw4 hover-white no-underline white-70 dn dib-ns pv2 ph3" href="{{ .Site.Home.Permalink }}" >
&copy; {{ with .Site.Copyright | default .Site.Title }} {{ . | safeHTML }} {{ now.Format "2006"}} {{ end }}
&copy; {{ with .Site.Copyright | compare.Default .Site.Title }} {{ . | safe.HTML }} {{ now.Format "2006"}} {{ end }}
</a>
<div>{{ partialCached "social/follow.html" . }}</div>
<div>{{ partials.IncludeCached "social/follow.html" . }}</div>
</div>
</footer>

View File

@ -1,14 +1,14 @@
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
{{ $featured_image := partials.Include "func/GetFeaturedImage.html" . }}
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
{{ $featured_image_class := site.Params.featured_image_class | default "cover bg-top" }}
{{ $featured_image_class := site.Params.featured_image_class | compare.Default "cover bg-top" }}
<header class="{{ $featured_image_class }}" style="background-image: url('{{ $featured_image }}');">
{{ $cover_dimming_class := site.Params.cover_dimming_class | default "bg-black-60" }}
{{ $cover_dimming_class := site.Params.cover_dimming_class | compare.Default "bg-black-60" }}
<div class="{{ $cover_dimming_class }}">
{{ partial "site-navigation.html" .}}
{{ partials.Include "site-navigation.html" .}}
<div class="tc-l pv4 pv6-l ph3 ph4-ns">
<h1 class="f2 f-subheadline-l fw2 white-90 mb0 lh-title">
{{ .Title | default .Site.Title }}
{{ .Title | compare.Default .Site.Title }}
</h1>
{{ with .Params.description }}
<h2 class="fw1 f5 f3-l white-80 measure-wide-l center mt3">
@ -20,11 +20,11 @@
</header>
{{ else }}
<header>
<div class="pb3-m pb6-l {{ .Site.Params.background_color_class | default "bg-black" }}">
{{ partial "site-navigation.html" . }}
<div class="pb3-m pb6-l {{ .Site.Params.background_color_class | compare.Default "bg-black" }}">
{{ partials.Include "site-navigation.html" . }}
<div class="tc-l pv3 ph3 ph4-ns">
<h1 class="f2 f-subheadline-l fw2 light-silver mb0 lh-title">
{{ .Title | default .Site.Title }}
{{ .Title | compare.Default .Site.Title }}
</h1>
{{ with .Params.description }}
<h2 class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">

View File

@ -2,25 +2,25 @@
<div class="flex-l justify-between items-center center">
<a href="{{ .Site.Home.RelPermalink }}" class="f3 fw2 hover-white no-underline white-90 dib">
{{ with .Site.Params.site_logo }}
<img src="{{ relURL . }}" class="w100 mw5-ns" alt="{{ $.Site.Title }}" />
<img src="{{ urls.RelURL . }}" class="w100 mw5-ns" alt="{{ $.Site.Title }}" />
{{ else }}
{{ .Site.Title }}
{{ end }}
</a>
<div class="flex-l items-center">
{{ partial "i18nlist.html" . }}
{{ partials.Include "i18nlist.html" . }}
{{ if .Site.Menus.main }}
<ul class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr0 ml3" "pl0 mr3" }}">
<ul class="{{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pr0 ml3" "pl0 mr3" }}">
{{ range .Site.Menus.main }}
<li class="list f5 f4-ns fw4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3" "pr3" }}">
<a class="hover-white no-underline white-90" href="{{ .URL }}" title="{{ i18n "pageTitle" . }}">
<li class="list f5 f4-ns fw4 dib {{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pl3" "pr3" }}">
<a class="hover-white no-underline white-90" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}">
{{ .Name }}
</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ partialCached "social/follow.html" . }}
{{ partials.IncludeCached "social/follow.html" . }}
</div>
</div>
</nav>

View File

@ -1,9 +1,9 @@
{{ with partialCached "func/style/GetMainCSS.html" "style/GetMainCSS" }}
{{ with partials.IncludeCached "func/style/GetMainCSS.html" "style/GetMainCSS" }}
<link rel="stylesheet" href="{{ .RelPermalink }}" >
{{ end }}
{{ range site.Params.custom_css }}
{{ with partialCached "func/style/GetResource.html" . . }}{{ else }}
<link rel="stylesheet" href="{{ relURL (.) }}">
{{ with partials.IncludeCached "func/style/GetResource.html" . . }}{{ else }}
<link rel="stylesheet" href="{{ urls.RelURL (.) }}">
{{ end }}
{{ end }}

View File

@ -6,27 +6,27 @@
<div class="ananke-socials">
{{- range $networks -}}
{{- $network := . -}}
{{- $setup := index $config.networks $network -}}
{{- $profile := index $config $network -}}
{{- $rel := $profile.rel | default "" -}}
{{- $label := $profile.label | default $setup.label -}}
{{- $setup := collections.Index $config.networks $network -}}
{{- $profile := collections.Index $config $network -}}
{{- $rel := $profile.rel | compare.Default "" -}}
{{- $label := $profile.label | compare.Default $setup.label -}}
{{- $link := (printf $setup.profile $profile.username) -}}
{{- $link := (fmt.Printf $setup.profile $profile.username) -}}
{{- with $profile.profilelink -}}
{{- $link = $profile.profilelink -}}
{{- end -}}
{{- $languageDirection := cond (eq $.Site.Language.LanguageDirection "rtl") "ml1" "mr1" -}}
{{- $languageDirection := compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "ml1" "mr1" -}}
<a href="{{ $link }}" target="_blank" rel="noopener{{- with $rel }} {{ . -}}{{- end -}}"
class="ananke-social-link link-transition {{ $network }} link dib z-999 pt3 pt0-l {{ $languageDirection }}"
title="follow on {{ $label }} - Opens in a new window"
aria-label="follow on {{ $label }} - Opens in a new window">
{{/* @todo add the following lines to a partial, reused in social/share.html */}}
{{- with $setup.icon -}}
{{- $icon := resources.Get (printf "ananke/socials/%s.svg" .) -}}
{{- $icon := resources.Get (fmt.Printf "ananke/socials/%s.svg" .) -}}
{{- with $icon -}}
<span class="icon">
{{ .Content | safeHTML }}
{{ .Content | safe.HTML }}
{{/* @todo indicator for missing or misconfigured icon */}}
</span>
{{- end -}}
@ -34,7 +34,7 @@
{{- $label -}}
{{- end -}}
{{- with $config.follow.new_window_icon -}}
{{- partial "new-window-icon.html" . -}}
{{- partials.Include "new-window-icon.html" . -}}
{{- end -}}
</a>
{{- end -}}

View File

@ -1,45 +1,45 @@
{{- $context := . -}}
{{- $disabled := $context.Params.disable_share | default "false" -}}
{{- $disabled := $context.Params.disable_share | compare.Default "false" -}}
{{- $config := site.Params.ananke.social -}}
{{- with $config.share.disable_share -}}
{{- $disabled := . -}}
{{- end -}}
{{- if eq "false" $disabled -}}
{{- if compare.Eq "false" $disabled -}}
{{- $title := $context.Title -}}
{{- $url := printf "%s" $context.Permalink | absLangURL -}}
{{- $url := fmt.Printf "%s" $context.Permalink | urls.AbsLangURL -}}
{{- $networks := $config.share.networks -}}
{{- $hasLabel := $config.share.sharetext | default "true" -}}
{{- $hasIcon := $config.share.icons | default "true" -}}
{{- $hasLabel := $config.share.sharetext | compare.Default "true" -}}
{{- $hasIcon := $config.share.icons | compare.Default "true" -}}
<div id="sharing" class="mt3 ananke-socials">
{{- range $networks -}}
{{- $network := . -}}
{{- $setup := index $config.networks $network -}}
{{/* @todo i18n $sharetext := lang.Translate (fmt.Printf "share_on_%s" $setup.slug) */}}
{{- $setup := collections.Index $config.networks $network -}}
{{/* @todo lang.Translate $sharetext := lang.Translate (fmt.Printf "share_on_%s" $setup.slug) */}}
{{- $label := "" -}}
{{ with $config.share.sharetext -}}
{{- $label = printf "Share on %s" $setup.label -}}
{{- $label = fmt.Printf "Share on %s" $setup.label -}}
{{- end -}}
{{ if eq $setup.share "false" | default "true" -}}
{{ if compare.Eq $setup.share "false" | compare.Default "true" -}}
{{- continue -}}
{{/* @todo notification into CLI that a network is configured but not supported */}}
{{- end -}}
{{- $options := (dict "context" page "setup" $setup) }}
{{- $href := partial "func/social/getShareLink.html" $options -}}
{{- $href := partials.Include "func/social/getShareLink.html" $options -}}
<a href="{{ $href }}"
class="ananke-social-link {{ $setup.slug }} no-underline"
title="{{ $label }}" aria-label="{{ $label }}"
target="_blank" rel="nofollow noopener noreferrer">
{{ with $config.share.icons -}}
{{/* @todo add the following lines to a partial, reused in social/follow.html */}}
{{/* @todo add the following lines to a partial, reused collections.In social/follow.html */}}
{{- with $setup.icon -}}
{{- $icon := resources.Get (printf "ananke/socials/%s.svg" .) -}}
{{- $icon := resources.Get (fmt.Printf "ananke/socials/%s.svg" .) -}}
{{- with $icon -}}
<span class="icon">
{{ .Content | safeHTML }}
{{ .Content | safe.HTML }}
{{/* @todo indicator for missing or misconfigured icon */}}
</span>
{{- end -}}
@ -53,4 +53,4 @@
{{- end -}}
</div>
{{- end -}} {{/* if eq "true" $disabled */}}
{{- end -}} {{/* if compare.Eq "true" $disabled */}}

View File

@ -1,19 +1,19 @@
{{ partial "func/warn.html" `You are currently using 'partial "summary-with-image"' in your project templates.
{{ partials.Include "func/warn.html" `You are currently using 'partial "summary-with-image"' in your project templates.
You should replace it with '.Render "summary-with-image"' as the use of this partial will be deprecated in future releases.
More info here: https://github.com/theNewDynamic/gohugo-theme-ananke/releases/tag/v2.8.1` }}
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
{{ $featured_image := partials.Include "func/GetFeaturedImage.html" . }}
<article class="bb b--black-10">
<div class="db pv4 ph3 ph0-l no-underline dark-gray">
<div class="no-underline db pv4 ph3 ph0-l dark-gray">
<div class="flex flex-column flex-row-ns">
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
<div class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }} mb4 mb0-ns w-100 w-40-ns">
<div class="{{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }} mb4 mb0-ns w-100 w-40-ns">
<a href="{{.RelPermalink}}" class="db grow">
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
</a>
</div>
{{ end }}
<div class="blah w-100{{ if $featured_image }} w-60-ns {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr3-ns" "pl3-ns" }}{{ end }}">
<div class="blah w-100{{ if $featured_image }} w-60-ns {{ compare.Conditional (compare.Eq $.Site.Language.LanguageDirection "rtl") "pr3-ns" "pl3-ns" }}{{ end }}">
<h1 class="f3 fw1 athelas mt0 lh-title">
<a href="{{.RelPermalink}}" class="color-inherit dim link">
{{ .Title }}
@ -22,10 +22,10 @@ More info here: https://github.com/theNewDynamic/gohugo-theme-ananke/releases/ta
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
{{ with .Params.author | default .Site.Params.author }}
{{ with .Params.author | compare.Default .Site.Params.author }}
<p class="f6 lh-copy mv0">By {{ . }}</p>
{{- end -}}
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | compare.Default (lang.Translate "readMore") }}</a>
</div>
</div>
</div>

View File

@ -1,9 +1,9 @@
{{ partial "func/warn.html" `You are currently using 'partial "summary"' in your project templates.
{{ partials.Include "func/warn.html" `You are currently using 'partial "summary"' in your project templates.
You should replace it with '.Render "summary"' as the use of this partial will be deprecated in future releases.
More info here: https://github.com/theNewDynamic/gohugo-theme-ananke/releases/tag/v2.8.1` }}
<div class="relative w-100 mb4 bg-white nested-copy-line-height">
<div class="bg-white mb3 pa4 gray overflow-hidden">
<span class="f6 db">{{ humanize .Section }}</span>
<div class="relative bg-white w-100 mb4 nested-copy-line-height">
<div class="overflow-hidden bg-white mb3 pa4 gray">
<span class="f6 db">{{ inflect.Humanize .Section }}</span>
<h1 class="f3 near-black">
<a href="{{ .RelPermalink }}" class="link black dim">
{{ .Title }}

View File

@ -3,12 +3,12 @@
This template is the same as the default and is here to demonstrate that if you have a content directory called "post" you can create a layouts directory, just for that section.
*/}}
<article class="pa3 pa4-ns nested-copy-line-height">
<section class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | default "mid-gray" }}">
<section class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | compare.Default "mid-gray" }}">
{{ .Content }}
</section>
<aside class="flex-ns flex-wrap justify-around mt5">
<aside class="flex-wrap justify-around flex-ns mt5">
{{ range .Paginator.Pages }}
<div class="relative w-100 w-30-l mb4 bg-white">
<div class="relative bg-white w-100 w-30-l mb4">
{{ .Render "summary" }}
</div>
{{ end }}

View File

@ -1,7 +1,7 @@
<div class="mb3 pa4 {{ $.Param "text_color" | default "mid-gray" }} overflow-hidden">
<div class="mb3 pa4 {{ $.Param "text_color" | compare.Default "mid-gray" }} overflow-hidden">
{{ if .Date }}
<div class="f6">
{{ .Date | time.Format (default "January 2, 2006" .Site.Params.date_format) }}
{{ .Date | time.Format (compare.Default "January 2, 2006" .Site.Params.date_format) }}
</div>
{{ end }}
<h1 class="f3 near-black">
@ -12,5 +12,5 @@
<div class="nested-links f5 lh-copy nested-copy-line-height">
{{ .Summary }}
</div>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | compare.Default (lang.Translate "readMore") }}</a>
</div>

View File

@ -2,7 +2,7 @@ User-agent: *
{{/* robotstxt.org - if we are in production, allow access, else deny */ -}}
{{ if hugo.IsProduction -}}
Allow: /
Sitemap: {{ "/sitemap.xml" | absURL }}
Sitemap: {{ "/sitemap.xml" | urls.AbsURL }}
{{ else -}}
Disallow: /
{{ end -}}

View File

@ -3,18 +3,18 @@
<form class="black-80 sans-serif" accept-charset="UTF-8" action="{{ .Get "action" }}" method="POST" role="form">
<label class="{{ $.Scratch.Get "labelClasses" }}" for="name">{{ i18n "yourName" }}</label>
<label class="{{ $.Scratch.Get "labelClasses" }}" for="name">{{ lang.Translate "yourName" }}</label>
<input type="text" id="name" name="name" class="{{ $.Scratch.Get "inputClasses" }}" required placeholder=" " aria-labelledby="name"/>
<label class="{{ $.Scratch.Get "labelClasses" }}" for="email">{{ i18n "emailAddress" }}</label>
<label class="{{ $.Scratch.Get "labelClasses" }}" for="email">{{ lang.Translate "emailAddress" }}</label>
<input type="email" id="email" name="email" class="{{ $.Scratch.Get "inputClasses" }}" required placeholder=" " aria-labelledby="email"/>
<div class="requirements f6 gray glow i ph3 overflow-hidden">
{{ i18n "emailRequiredNote" }}
{{ lang.Translate "emailRequiredNote" }}
</div>
<label class="{{ $.Scratch.Get "labelClasses" }}" for="message">{{ i18n "message" }}</label>
<label class="{{ $.Scratch.Get "labelClasses" }}" for="message">{{ lang.Translate "message" }}</label>
<textarea id="message" name="message" class="{{ $.Scratch.Get "inputClasses" }} h4" aria-labelledby="message"></textarea>
<input class="db w-100 mv2 white pa3 bn hover-shadow hover-bg-black bg-animate bg-black" type="submit" value="{{ i18n "send" }}" />
<input class="db w-100 mv2 white pa3 bn hover-shadow hover-bg-black bg-animate bg-black" type="submit" value="{{ lang.Translate "send" }}" />
</form>