From 3ae446e96df8e92b382d9d8d971510a76b9c951b Mon Sep 17 00:00:00 2001
From: Gabriele Musco
Date: Sat, 2 Apr 2022 16:40:40 +0200
Subject: [PATCH] added article main image caption; added option to show toc
before the main article image
---
README.md | 2 ++
layouts/partials/single_post.html | 21 ++++++++++++++-------
layouts/partials/toc.html | 4 ++++
3 files changed, 20 insertions(+), 7 deletions(-)
create mode 100644 layouts/partials/toc.html
diff --git a/README.md b/README.md
index 5b1d54f..c78b616 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,7 @@ summaryLength = 70 # number of words for article summaries
plausibleDomain = "example.com"
enableShareOnFediverse = false # enable a button at the end of an article to share it on the fediverse
+ tocBeforeImage = false # show the table of contents before the main article image; default false
# WARNING: deprecated! Use [[menu.icons]] instead, look below
# links = [
@@ -254,6 +255,7 @@ Every post can have various parameters in the frontmatter, here are some that yo
- `description`: a brief description of the post, useful for SEO optimization
- `tags`: an array of tags, useful for searching similar articles
- `image`: a link to a feature image for the article, shown in the preview as well
+- `imageCaption`: a markdown text rendered as a caption for the article image described above
- `featured`: boolean, indicate if the post should be shown as featured
- `comments`: boolean, if true it enables comments for the current post, if false it disables them (default is true)
- `showDate`: boolean, true by default, if false hides the date. Useful for non-article pages where the date isn't important
diff --git a/layouts/partials/single_post.html b/layouts/partials/single_post.html
index 0972df4..756081b 100644
--- a/layouts/partials/single_post.html
+++ b/layouts/partials/single_post.html
@@ -9,14 +9,21 @@
{{- partial "date.html" .Date -}}
{{ end }}
- {{ if .Params.Image }}
-
+ {{ if and (.Params.toc | default false) (.Site.Params.tocBeforeImage | default false) }}
+ {{- partial "toc.html" . -}}
{{ end }}
- {{ if (.Params.toc | default false) }}
-
- {{ .TableOfContents }}
-
-
+ {{ if .Params.Image }}
+
+ {{ end }}
+ {{ if and (.Params.toc | default false) (not (.Site.Params.tocBeforeImage | default false)) }}
+ {{- partial "toc.html" . -}}
{{ end }}
{{ .Content }}
diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html
new file mode 100644
index 0000000..d99f4d7
--- /dev/null
+++ b/layouts/partials/toc.html
@@ -0,0 +1,4 @@
+