From f21ac49b08a5a108167f1afc4e8a307a86bfc51b Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 23 Apr 2023 22:02:11 +0900 Subject: [PATCH] Add a table of contents Create a new table_of_contents partial that includes an auto-generated table of contents if the word count is over 400 and the "toc" page variable has been set true. --- layouts/_default/term.html | 2 ++ layouts/partials/photo_exif_table.html | 2 +- layouts/partials/table_of_contents.html | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/table_of_contents.html diff --git a/layouts/_default/term.html b/layouts/_default/term.html index 23491df..908d208 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -7,6 +7,8 @@

{{ .Title }}

+{{ partial "table_of_contents.html" . }} + {{- $hasContent := false -}} {{ with .Content }} {{- $hasContent = true -}} diff --git a/layouts/partials/photo_exif_table.html b/layouts/partials/photo_exif_table.html index fbd229f..a212c98 100644 --- a/layouts/partials/photo_exif_table.html +++ b/layouts/partials/photo_exif_table.html @@ -49,7 +49,7 @@ {{- $focalLength := .Tags.FocalLengthIn35mmFilm | default .Tags.FocalLength -}} {{- with $focalLength -}}{{ . }} mm{{- end -}} - {{ with .Tags.FNumber }}ƒ{{ . }}{{ end }} + {{ with .Tags.FNumber }}{{ printf "ƒ%0.1f" . }}{{ end }} {{- with $exposureTime := .Tags.ExposureTime -}} {{- if in $exposureTime "/" -}} diff --git a/layouts/partials/table_of_contents.html b/layouts/partials/table_of_contents.html new file mode 100644 index 0000000..70a2f45 --- /dev/null +++ b/layouts/partials/table_of_contents.html @@ -0,0 +1,8 @@ +{{ if and (gt .WordCount 400) .Params.toc }} + +{{ end }}