From 5c60561ddb409d5633cfdc76e0735fbbbe1bc171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 13 Mar 2024 18:42:52 +0100 Subject: [PATCH] Website: allow separate page title for TOC You can now set a page title and a separate title for the table of contents with: ``` --- title: "Manager Configuration: MQTT" titleTOC: MQTT --- ``` --- .../layouts/partials/menu-filetree.html | 4 ++-- .../layouts/partials/utils/title-toc.html | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 web/project-website/themes/hugo-geekdoc/layouts/partials/utils/title-toc.html diff --git a/web/project-website/themes/hugo-geekdoc/layouts/partials/menu-filetree.html b/web/project-website/themes/hugo-geekdoc/layouts/partials/menu-filetree.html index e51a5de0..8790fc64 100644 --- a/web/project-website/themes/hugo-geekdoc/layouts/partials/menu-filetree.html +++ b/web/project-website/themes/hugo-geekdoc/layouts/partials/menu-filetree.html @@ -71,11 +71,11 @@ {{- printf " is-active" }} {{- end }}" > - {{ partial "utils/title" . }} + {{ partial "utils/title-toc" . }} {{ else }} - {{ partial "utils/title" . }} + {{ partial "utils/title-toc" . }} {{ end }} {{ if $doCollapse }} diff --git a/web/project-website/themes/hugo-geekdoc/layouts/partials/utils/title-toc.html b/web/project-website/themes/hugo-geekdoc/layouts/partials/utils/title-toc.html new file mode 100644 index 00000000..cb733329 --- /dev/null +++ b/web/project-website/themes/hugo-geekdoc/layouts/partials/utils/title-toc.html @@ -0,0 +1,13 @@ +{{ $title := "" }} + +{{ if .Page.Params.TitleTOC }} + {{ $title = .Page.Params.TitleTOC }} +{{ else if .Title }} + {{ $title = .Title }} +{{ else if and .IsSection .File }} + {{ $title = path.Base .File.Dir | humanize | title }} +{{ else if and .IsPage .File }} + {{ $title = .File.BaseFileName | humanize | title }} +{{ end }} + +{{ return $title }}