From f8541ef965ca22e746b523eb418e47cb4f78f2d8 Mon Sep 17 00:00:00 2001 From: Arne Rief Date: Fri, 9 Jan 2026 12:24:05 +0100 Subject: Upgrade to new template system from Hugo v0.146.0 --- layouts/_partials/footer.html | 41 ++++++++++++++++++++ layouts/_partials/head/css.html | 21 ++++++++++ layouts/_partials/head/js.html | 16 ++++++++ layouts/_partials/head/meta.html | 27 +++++++++++++ layouts/_partials/head/seo.html | 46 ++++++++++++++++++++++ layouts/_partials/header.html | 14 +++++++ layouts/_partials/list/pagination.html | 28 ++++++++++++++ layouts/_partials/list/post-card.html | 66 ++++++++++++++++++++++++++++++++ layouts/_partials/list/recent-posts.html | 45 ++++++++++++++++++++++ layouts/_partials/navmenu.html | 48 +++++++++++++++++++++++ layouts/_partials/select-language.html | 38 ++++++++++++++++++ layouts/_partials/select-theme.html | 15 ++++++++ layouts/_partials/single/next-prev.html | 44 +++++++++++++++++++++ layouts/_partials/single/tags.html | 17 ++++++++ 14 files changed, 466 insertions(+) create mode 100644 layouts/_partials/footer.html create mode 100644 layouts/_partials/head/css.html create mode 100644 layouts/_partials/head/js.html create mode 100644 layouts/_partials/head/meta.html create mode 100644 layouts/_partials/head/seo.html create mode 100644 layouts/_partials/header.html create mode 100644 layouts/_partials/list/pagination.html create mode 100644 layouts/_partials/list/post-card.html create mode 100644 layouts/_partials/list/recent-posts.html create mode 100644 layouts/_partials/navmenu.html create mode 100644 layouts/_partials/select-language.html create mode 100644 layouts/_partials/select-theme.html create mode 100644 layouts/_partials/single/next-prev.html create mode 100644 layouts/_partials/single/tags.html (limited to 'layouts/_partials') diff --git a/layouts/_partials/footer.html b/layouts/_partials/footer.html new file mode 100644 index 0000000..a0a30b2 --- /dev/null +++ b/layouts/_partials/footer.html @@ -0,0 +1,41 @@ + diff --git a/layouts/_partials/head/css.html b/layouts/_partials/head/css.html new file mode 100644 index 0000000..d4e894e --- /dev/null +++ b/layouts/_partials/head/css.html @@ -0,0 +1,21 @@ +{{- with resources.Get "css/main.css" -}} + {{- $allStylesheets := slice + . + (resources.Get "css/header.css") + (resources.Get "css/navmenu.css") + (resources.Get "css/footer.css") + (resources.Get "css/post-card.css") + (resources.Get "css/page.css") + (resources.Get "css/post.css") + (resources.Get "css/list-navigation.css") + (resources.Get "css/search.css") + -}} + {{- $cssBundle := $allStylesheets | resources.Concat "css/bundle.css" -}} + + {{- if hugo.IsDevelopment -}} + + {{- else -}} + {{- $css := $cssBundle | minify | fingerprint -}} + + {{- end -}} +{{- end -}} diff --git a/layouts/_partials/head/js.html b/layouts/_partials/head/js.html new file mode 100644 index 0000000..0baf831 --- /dev/null +++ b/layouts/_partials/head/js.html @@ -0,0 +1,16 @@ +{{- with resources.Get "js/main.js" }} + {{- $opts := dict + "minify" (not hugo.IsDevelopment) + "sourceMap" (cond hugo.IsDevelopment "external" "") + "targetPath" "js/main.js" + }} + {{- with . | js.Build $opts }} + {{- if hugo.IsDevelopment }} + + {{- else }} + {{- with . | fingerprint }} + + {{- end }} + {{- end }} + {{- end }} +{{- end -}} diff --git a/layouts/_partials/head/meta.html b/layouts/_partials/head/meta.html new file mode 100644 index 0000000..f739838 --- /dev/null +++ b/layouts/_partials/head/meta.html @@ -0,0 +1,27 @@ +{{- /* Basic Meta */ -}} + + + +{{- /* Open Graph */ -}} + + + + + +{{- with site.Params.logo }} + +{{- end }} +{{- if .IsPage }} + + {{- with .Lastmod }} + + {{- end }} +{{- end }} + +{{- /* Twitter Card */ -}} + + + +{{- with site.Params.logo }} + +{{- end }} diff --git a/layouts/_partials/head/seo.html b/layouts/_partials/head/seo.html new file mode 100644 index 0000000..628ea2c --- /dev/null +++ b/layouts/_partials/head/seo.html @@ -0,0 +1,46 @@ + diff --git a/layouts/_partials/header.html b/layouts/_partials/header.html new file mode 100644 index 0000000..f38b6f2 --- /dev/null +++ b/layouts/_partials/header.html @@ -0,0 +1,14 @@ + diff --git a/layouts/_partials/list/pagination.html b/layouts/_partials/list/pagination.html new file mode 100644 index 0000000..dfe8178 --- /dev/null +++ b/layouts/_partials/list/pagination.html @@ -0,0 +1,28 @@ +{{- $paginator := . }} +{{- if gt $paginator.TotalPages 1 }} + +{{- end }} diff --git a/layouts/_partials/list/post-card.html b/layouts/_partials/list/post-card.html new file mode 100644 index 0000000..6444701 --- /dev/null +++ b/layouts/_partials/list/post-card.html @@ -0,0 +1,66 @@ +{{- /* +Card with a summary of and link to a post. Accepts a dict with the following parameters: + +@context {Page} post: The post to display. +@context {bool} show_section: Whether to display a badge with the name of the section the post was published under (default: false). + +@example: {{ partial "list/post-card.html" (dict "post" . "show_section" true) }} +*/ -}} + +{{- $post := .post -}} +{{- $showSection := .show_section | default false -}} +
+
+

+ + {{ $post.Title }} + +

+
+ + + {{- if $showSection }} + + {{ lang.Translate ($post.Section | singularize) | default ($post.Section | singularize | title) }} + + {{- end }} +
+
+ + {{- with $post.Summary }} +
+ {{ . }} +
+ {{- end }} + + {{- with $post.Params.tags }} +
+
    + {{- range first 3 . }} +
  • + #{{ . }} +
  • + {{- end }} + {{- if gt (len .) 3 }} +
  • + + +{{ sub (len .) 3 }} {{ lang.Translate "more" | default "more" }} + +
  • + {{- end }} +
+
+ {{- end }} +
diff --git a/layouts/_partials/list/recent-posts.html b/layouts/_partials/list/recent-posts.html new file mode 100644 index 0000000..464e9f7 --- /dev/null +++ b/layouts/_partials/list/recent-posts.html @@ -0,0 +1,45 @@ +{{- /* +List of specified number of the most recent and published posts. Accepts a dict with the following optional parameters: + +@context {int} count: Number of posts to display (default: 10). +@context {string} title: Section title (default: "Recent Articles"). +@context {bool} show_view_all: Whether to show "View All Posts" link (default: true). + +@example: {{ partial "list/recent-posts.html" (dict "count" 20 "title" "Latest updates" "show_view_all" true) }} +*/ -}} + +{{- $count := .count | default 10 -}} +{{- $title := .title | default (lang.Translate "posts_recent" | default "Recent Articles") -}} +{{- $showViewAll := .show_view_all | default true -}} +
+
+

+ {{ $title }} +

+
+ + {{- $recentPosts := where site.RegularPages "Params.excludeFromLists" "!=" true | first $count }} + {{- if $recentPosts }} +
+
    + {{- range $recentPosts }} +
  • + {{- partial "list/post-card.html" (dict "post" . "show_section" true) }} +
  • + {{- end }} +
+ + {{- if $showViewAll }} + {{- with site.GetPage "/all-posts"}} + + {{ lang.Translate "posts_all_view" | default "View all posts" }} » + + {{- end }} + {{- end }} +
+ {{ else }} +

+ {{ lang.Translate "list_empty" | default "No posts in this section." }} +

+ {{- end }} +
diff --git a/layouts/_partials/navmenu.html b/layouts/_partials/navmenu.html new file mode 100644 index 0000000..af0fc2e --- /dev/null +++ b/layouts/_partials/navmenu.html @@ -0,0 +1,48 @@ +{{- /* +Simplified version of the `hugo new template` menu.html default. Renders a menu for the given menu ID. + +@context {page} page: The current page. +@context {string} menuID: The menu ID. + +@example: {{ partial "navmenu.html" (dict "menuID" "main" "page" .) }} +*/}} + +{{- $currentPage := .page }} +{{- $menuID := .menuID }} + +{{- with index site.Menus $menuID }} + +{{- end -}} diff --git a/layouts/_partials/select-language.html b/layouts/_partials/select-language.html new file mode 100644 index 0000000..6efcc61 --- /dev/null +++ b/layouts/_partials/select-language.html @@ -0,0 +1,38 @@ +{{- /* +Selection of available languages. +Dynamically links to corresponding page/post if a translated version exists, otherwise to homepage of that language as fallback. + +Note: `$activeLang` and `$allTranslationsForPage` are technically unnecessary variables, their values could be called with `$.Lang` and `$.Translations` respectively. +These variables - together with the explicit naming of `.` context variables in other cases - were chosen for better readability and understandability of the code. +*/ -}} + +{{- if gt (len site.Languages) 1 }} +{{- $activeLang := .Lang }} +{{- $allTranslationsForPage := .Translations }} +
+ +
+{{- end }} diff --git a/layouts/_partials/select-theme.html b/layouts/_partials/select-theme.html new file mode 100644 index 0000000..914eacc --- /dev/null +++ b/layouts/_partials/select-theme.html @@ -0,0 +1,15 @@ + diff --git a/layouts/_partials/single/next-prev.html b/layouts/_partials/single/next-prev.html new file mode 100644 index 0000000..932fcac --- /dev/null +++ b/layouts/_partials/single/next-prev.html @@ -0,0 +1,44 @@ +{{- /* Navigation for next & previous post and back to top */ -}} +{{- if ne .Params.excludeFromLists true }} + + + + + +{{- end }} diff --git a/layouts/_partials/single/tags.html b/layouts/_partials/single/tags.html new file mode 100644 index 0000000..0c10d20 --- /dev/null +++ b/layouts/_partials/single/tags.html @@ -0,0 +1,17 @@ +{{- with .GetTerms "tags" }} +
+ + + +
+{{- end }} -- cgit v1.2.3