diff --git a/CHANGELOG.md b/CHANGELOG.md index d55a1a61..118c934c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added +- Front matter support for specifying article thumbnails, covers and featured image details (including filename pattern, alt text and caption) - Front matter keywords support on a per article basis - Indonesian translation ([#398](https://github.com/jpanther/congo/pull/398)) - Mastodon sharing links ([#405](https://github.com/jpanther/congo/pull/405)) diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css index 67dc7632..f53854ab 100644 --- a/assets/css/compiled/main.css +++ b/assets/css/compiled/main.css @@ -1798,6 +1798,10 @@ body:has(#menu-controller:checked) { margin-top: -1rem; } +.-mt-3 { + margin-top: -0.75rem; +} + .mr-2 { margin-right: 0.5rem; } diff --git a/exampleSite/content/docs/front-matter.md b/exampleSite/content/docs/front-matter.md index 69ad5bd9..48b7318e 100644 --- a/exampleSite/content/docs/front-matter.md +++ b/exampleSite/content/docs/front-matter.md @@ -16,6 +16,13 @@ Front matter parameter default values are inherited from the theme's [base confi |---|---|---| |`title`|_Not set_|The name of the article.| |`description`|_Not set_|The text description for the article. It is used in the HTML metadata.| +|`feature`|`"*feature*"`|The text pattern to match the feature image filename for this article.| +|`featureAlt`|`""`|The alternative text description for the feature image.| +|`cover`|`"*cover*"`|The text pattern to match the cover image filename for this article.| +|`coverAlt`|`featureAlt`|The alternative text description for the cover image.| +|`coverCaption`|_Not set_|The figure caption text to be displayed beneath the cover image.| +|`thumbnail`|`"*thumb*"`_|The text pattern to match the thumbnail image filename for this article.| +|`thumbnailAlt`|`featureAlt`|The alternative text description for the thumbnail image.| |`externalUrl`|_Not set_|If this article is published on a third-party website, the URL to this article. Providing a URL will prevent a content page being generated and any references to this article will link directly to the third-party website.| |`editURL`|`article.editURL`|When `showEdit` is active, the URL for the edit link.| |`editAppendPath`|`article.editAppendPath`|When `showEdit` is active, whether or not the path to the current article should be appended to the URL set at `editURL`.| diff --git a/exampleSite/content/samples/rich-content/index.md b/exampleSite/content/samples/rich-content/index.md index efe6bb76..4f750427 100755 --- a/exampleSite/content/samples/rich-content/index.md +++ b/exampleSite/content/samples/rich-content/index.md @@ -3,6 +3,8 @@ title: "Rich Content" date: 2019-03-10 description: "A brief description of Hugo Shortcodes" summary: "This is an _example_ of a **rich** content summary." +coverAlt: "An example cover image depicting icons of some popular media organisations." +coverCaption: "This is an example cover image with a caption." tags: ["shortcodes", "privacy", "sample", "gist", "twitter", "youtube", "vimeo"] --- diff --git a/layouts/_default/single.html b/layouts/_default/single.html index fcf09b8b..557f6995 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,7 +1,7 @@ {{ define "main" }} {{- $images := .Resources.ByType "image" }} - {{- $cover := $images.GetMatch "*cover*" }} - {{- $feature := $images.GetMatch "*feature*" | default $cover }} + {{- $cover := $images.GetMatch (.Params.cover | default "*cover*") }} + {{- $feature := $images.GetMatch (.Params.feature | default "*feature*") | default $cover }}
{{ if .Params.showBreadcrumbs | default (.Site.Params.article.showBreadcrumbs | default false) }} @@ -14,15 +14,21 @@ {{ partial "article-meta.html" (dict "context" . "scope" "single") }} {{ with $feature }} - +
+ {{ $.Params.featureAlt | default $.Params.coverAlt | default + {{ with $.Params.coverCaption }} +
{{ . | markdownify }}
+ {{ end }} +
{{ end }}
diff --git a/layouts/partials/article-link.html b/layouts/partials/article-link.html index 03491047..8c92bd49 100644 --- a/layouts/partials/article-link.html +++ b/layouts/partials/article-link.html @@ -1,7 +1,7 @@
{{- $images := $.Resources.ByType "image" }} - {{- $thumbnail := $images.GetMatch "*thumb*" }} - {{- $feature := $images.GetMatch "*feature*" | default $thumbnail }} + {{- $thumbnail := $images.GetMatch (.Params.thumbnail | default "*thumb*") }} + {{- $feature := $images.GetMatch (.Params.feature | default "*feature*") | default $thumbnail }} {{- with $feature }}