From 337a554a255138531e58b733e17c149719c19243 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 5 Mar 2020 20:37:58 +0000 Subject: [PATCH] feat(widget): add option to link to archive from Feature widget (#1557) To add a "See all" link underneath featured content, set `link_to_archive = true` under the `[content]` section in the front matter of the Featured widget. --- exampleSite/content/home/featured.md | 3 +++ layouts/partials/widgets/featured.html | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/exampleSite/content/home/featured.md b/exampleSite/content/home/featured.md index 345b6eac..f3df47e5 100644 --- a/exampleSite/content/home/featured.md +++ b/exampleSite/content/home/featured.md @@ -21,6 +21,9 @@ subtitle = "" # Page order. Descending (desc) or ascending (asc) date. order = "desc" + # Show a "See all pages" link underneath the featured content? + link_to_archive = false + # Filter posts by a taxonomy term. [content.filters] tag = "" diff --git a/layouts/partials/widgets/featured.html b/layouts/partials/widgets/featured.html index 91bb1f91..af8aaaac 100644 --- a/layouts/partials/widgets/featured.html +++ b/layouts/partials/widgets/featured.html @@ -9,6 +9,7 @@ {{/* Query */}} {{ $query := where (where site.RegularPages "Type" $items_type) "Params.featured" true }} +{{ $archive_page := site.GetPage "Section" $items_type }} {{/* Filters */}} {{ if $st.Params.content.filters.tag }} @@ -31,6 +32,18 @@ {{/* Limit */}} {{ $query = first $items_count $query }} +{{/* Localisation */}} +{{ $i18n := "" }} +{{ if eq $items_type "post" }} + {{ $i18n = "more_posts" }} +{{ else if eq $items_type "talk" }} + {{ $i18n = "more_talks" }} +{{ else if eq $items_type "publication" }} + {{ $i18n = "more_publications" }} +{{ else }} + {{ $i18n = "more_pages" }} +{{ end }} +

{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}

@@ -52,5 +65,14 @@ {{ end }} {{end}} + {{ if $st.Params.content.link_to_archive }} + + {{ end }} +