added article main image caption; added option to show toc before the main article image

This commit is contained in:
Gabriele Musco 2022-04-02 16:40:40 +02:00
parent a5e5a57aec
commit 3ae446e96d
No known key found for this signature in database
GPG Key ID: 0587A5D65B5DC99E
3 changed files with 20 additions and 7 deletions

View File

@ -108,6 +108,7 @@ summaryLength = 70 # number of words for article summaries
plausibleDomain = "example.com" plausibleDomain = "example.com"
enableShareOnFediverse = false # enable a button at the end of an article to share it on the fediverse 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 # WARNING: deprecated! Use [[menu.icons]] instead, look below
# links = [ # 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 - `description`: a brief description of the post, useful for SEO optimization
- `tags`: an array of tags, useful for searching similar articles - `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 - `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 - `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) - `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 - `showDate`: boolean, true by default, if false hides the date. Useful for non-article pages where the date isn't important

View File

@ -9,14 +9,21 @@
{{- partial "date.html" .Date -}} {{- partial "date.html" .Date -}}
</p> </p>
{{ end }} {{ end }}
{{ if .Params.Image }} {{ if and (.Params.toc | default false) (.Site.Params.tocBeforeImage | default false) }}
<img src="{{ .Params.Image }}" alt="" /> {{- partial "toc.html" . -}}
{{ end }} {{ end }}
{{ if (.Params.toc | default false) }} {{ if .Params.Image }}
<div class="articleToc"> <figure style="margin: 0">
{{ .TableOfContents }} <img src="{{ .Params.Image }}" alt="" />
<hr /> {{ if .Params.ImageCaption }}
</div> <figcaption>
<p>{{ .Params.ImageCaption | markdownify }}</p>
</figcaption>
{{ end }}
</figure>
{{ end }}
{{ if and (.Params.toc | default false) (not (.Site.Params.tocBeforeImage | default false)) }}
{{- partial "toc.html" . -}}
{{ end }} {{ end }}
<div>{{ .Content }}</div> <div>{{ .Content }}</div>
</article> </article>

View File

@ -0,0 +1,4 @@
<div class="articleToc">
{{ .TableOfContents }}
<hr />
</div>