From ec482bb3de52d39b2b0b027bf7687756c48bb61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Mon, 30 Oct 2023 23:22:25 +0100 Subject: [PATCH] taxonomy: warn on missing term title #709 --- exampleSite/content/tags/its-hidden/_index.en.md | 7 +++++-- exampleSite/content/tags/its-hidden/_index.pir.md | 1 + layouts/_default/taxonomy.html | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/exampleSite/content/tags/its-hidden/_index.en.md b/exampleSite/content/tags/its-hidden/_index.en.md index 9e7e3d0fa5..b4c904319a 100644 --- a/exampleSite/content/tags/its-hidden/_index.en.md +++ b/exampleSite/content/tags/its-hidden/_index.en.md @@ -2,9 +2,12 @@ title = "a secret" +++ -This lists all pages that are hidden from the home page. This includes pages that define `hidden=true` in their frontmatter as weill as descendents of hidden pages. +This lists all pages that are hidden from the home page. This includes pages that define `hidden=true` in their frontmatter as well as descendents of hidden pages. + +When giving term pages, you should give it a title. Otherwise it will print out a warning and will use the urlized title, which may looks weird. + +While internally this term is called `hidden`, it is referenced in the resulting english pages as `a secret` and as `hush, matey` in the piratish translation. -This tag also has a title. While internally it is called `hidden`, it is referenced in the resulting pages as `a secret`. ## Just an example heading diff --git a/exampleSite/content/tags/its-hidden/_index.pir.md b/exampleSite/content/tags/its-hidden/_index.pir.md index 969c22916c..fac21fd466 100644 --- a/exampleSite/content/tags/its-hidden/_index.pir.md +++ b/exampleSite/content/tags/its-hidden/_index.pir.md @@ -1,3 +1,4 @@ +++ +title = "hush, matey" +++ {{< piratify >}} \ No newline at end of file diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 90b7284f41..b0895b4df1 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -14,6 +14,9 @@ {{- $terms := slice }} {{- range .Data.Terms }} {{- $terms = $terms | append (dict "Title" (default .Page.Data.Term .Page.Title) "Term" . )}} + {{- if not .Page.Title }} + {{- warnf "%q: You have not given a 'title' in the frontmatter of your term page, the urlized title will be used instead" .Page.File.Filename }} + {{- end }} {{- end }} {{- range sort $terms ".Title" }} {{- $capital := substr .Title 0 1 | upper }}