diff --git a/exampleSite/content/home/posts.md b/exampleSite/content/home/posts.md index 9506cc72..5ce9af9f 100644 --- a/exampleSite/content/home/posts.md +++ b/exampleSite/content/home/posts.md @@ -62,5 +62,5 @@ subtitle = "" css_style = "" # CSS class. - css_class = "" + css_class = "" +++ diff --git a/exampleSite/content/home/publications.md b/exampleSite/content/home/publications.md index 876271ce..3f4427c7 100644 --- a/exampleSite/content/home/publications.md +++ b/exampleSite/content/home/publications.md @@ -62,7 +62,7 @@ subtitle = "" css_style = "" # CSS class. - css_class = "" + css_class = "" +++ {{% alert note %}} diff --git a/exampleSite/content/home/publications_featured.md b/exampleSite/content/home/publications_featured.md index 68ef514d..669eb0c4 100644 --- a/exampleSite/content/home/publications_featured.md +++ b/exampleSite/content/home/publications_featured.md @@ -1,32 +1,63 @@ +++ -# Featured Publications widget. -# This widget displays publications from `content/publication/` which have +# A Featured Publications section created with the Featured Content widget. +# This section displays publications from `content/publication/` which have # `featured = true` in their front matter. -widget = "publications_featured" # Do not modify this line! + +widget = "featured" # Do not modify this line! active = true # Activate this widget? true/false +weight = 10 # Order that this section will appear. title = "Featured Publications" subtitle = "" -# Order that this section will appear in. -weight = 10 +[content] + # Page type to display. E.g. post, talk, or publication. + page_type = "publication" + + # Choose how much pages you would like to display (0 = all pages) + count = 0 -# View. -# 1 = List -# 2 = Compact -# 3 = Card -# 4 = Citation -view = 3 + # Page order. Descending (desc) or ascending (asc) date. + order = "desc" -# Filter by publication type. -# -1: Any -# 0: Uncategorized -# 1: Conference proceedings -# 2: Journal -# 3: Work in progress -# 4: Technical report -# 5: Book -# 6: Book chapter -publication_type = "-1" + # Filter posts by a taxonomy term. + [content.filters] + tag = "" + category = "" + publication_type = "" + +[design] + # Toggle between the various page layout types. + # 1 = List + # 2 = Compact + # 3 = Card + # 4 = Citation (publication only) + view = 3 + +[design.background] + # Apply a background color, gradient, or image. + # Uncomment (by removing `#`) an option to apply it. + # Choose a light or dark text color by setting `text_color_light`. + # Any HTML color name or Hex value is valid. + + # Background color. + # color = "navy" + + # Background gradient. + # gradient_start = "DeepSkyBlue" + # gradient_end = "SkyBlue" + + # Background image. + # image = "background.jpg" # Name of image in `static/img/`. + # image_darken = 0.6 # Darken the image? Range 0-1 where 0 is transparent and 1 is opaque. + + # Text color (true=light or false=dark). + # text_color_light = true + +[advanced] + # Custom CSS. + css_style = "" + + # CSS class. + css_class = "" +++ - diff --git a/exampleSite/content/home/talks.md b/exampleSite/content/home/talks.md index 25319efd..81074408 100644 --- a/exampleSite/content/home/talks.md +++ b/exampleSite/content/home/talks.md @@ -62,5 +62,5 @@ subtitle = "" css_style = "" # CSS class. - css_class = "" + css_class = "" +++ diff --git a/exampleSite/content/home/talks_featured.md b/exampleSite/content/home/talks_featured.md deleted file mode 100644 index b02b5e34..00000000 --- a/exampleSite/content/home/talks_featured.md +++ /dev/null @@ -1,17 +0,0 @@ -+++ -# Featured Talks widget. -widget = "talks_featured" # Do not modify this line! -active = false # Activate this widget? true/false - -title = "Featured Talks" -subtitle = "" - -# Order that this section will appear in. -weight = 29 - -# View. -# 1 = List -# 2 = Compact -# 3 = Card -view = 3 -+++ diff --git a/layouts/partials/widgets/featured.html b/layouts/partials/widgets/featured.html new file mode 100644 index 00000000..1cbb6f2a --- /dev/null +++ b/layouts/partials/widgets/featured.html @@ -0,0 +1,61 @@ +{{/* Featured Content Widget */}} + +{{/* Initialise */}} +{{ $ := .root }} +{{ $st := .page }} +{{ $items_type := $st.Params.content.page_type | default "post" }} +{{ $items_count := $st.Params.content.count | default 65535 }} +{{ $items_sort := $st.Params.content.order| default "desc" }} + +{{/* Query */}} +{{ $query := where (where $.Site.RegularPages "Type" $items_type) "Params.featured" true }} + +{{/* Filters */}} +{{ if $st.Params.content.filters.tag }} + {{ $archive_page := $.Site.GetPage (printf "tags/%s" $st.Params.filters.content.tag) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} +{{ if $st.Params.content.filters.category }} + {{ $archive_page := $.Site.GetPage (printf "categories/%s" $st.Params.filters.content.category) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} +{{ if $st.Params.content.filters.publication_type }} + {{ $archive_page := $.Site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} + +{{/* Sort */}} +{{ $sort_by := "" }} +{{ if eq $items_type "talk" }} + {{ $sort_by = "Params.time_start" }} +{{ else }} + {{ $sort_by = "Date" }} +{{ end }} +{{ $query = sort $query $sort_by $items_sort }} + +{{/* Limit */}} +{{ $query = first $items_count $query }} + +
+
+

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

+ {{ with $st.Params.subtitle }}

{{ . | markdownify | emojify }}

{{ end }} +
+
+ + {{ with $st.Content }}

{{ . }}

{{ end }} + + {{ range $post := $query }} + {{ if eq $st.Params.design.view 1 }} + {{ partial "li_list" . }} + {{ else if eq $st.Params.design.view 3 }} + {{ partial "li_card" . }} + {{ else if eq $st.Params.design.view 3 | and (eq $st.Type "publication") }} + {{ partial "li_citation" . }} + {{ else }} + {{ partial "li_compact" . }} + {{ end }} + {{end}} + +
+
diff --git a/layouts/partials/widgets/pages.html b/layouts/partials/widgets/pages.html index 4cef5906..efc53903 100644 --- a/layouts/partials/widgets/pages.html +++ b/layouts/partials/widgets/pages.html @@ -5,8 +5,13 @@ {{ $st := .page }} {{ $items_type := $st.Params.content.page_type | default "post" }} {{ $items_offset := $st.Params.content.offset | default 0 }} -{{ $items_count := $st.Params.content.count | default 5 }} -{{ $items_sort := $st.Params.content.order| default "desc" }} +{{ $items_count := $st.Params.content.count }} +{{ if eq $items_count 0 }} + {{ $items_count = 65535 }} +{{ else }} + {{ $items_count = $items_count | default 5 }} +{{ end }} +{{ $items_sort := $st.Params.content.order | default "desc" }} {{/* Query */}} {{ $query := where $.Site.RegularPages "Type" $items_type }} @@ -29,13 +34,6 @@ {{ $query = where $query "Params.featured" "!=" true }} {{ end }} -{{/* Offset */}} -{{ if gt $items_offset 0 }} - {{ $query = first $items_count (after $items_offset $query) }} -{{ else }} - {{ $query = first $items_count $query }} -{{ end }} - {{/* Sort */}} {{ $sort_by := "" }} {{ if eq $items_type "talk" }} @@ -43,8 +41,15 @@ {{ else }} {{ $sort_by = "Date" }} {{ end }} - {{ $query = sort $query $sort_by $items_sort }} + +{{/* Offset and Limit */}} +{{ if gt $items_offset 0 }} + {{ $query = first $items_count (after $items_offset $query) }} +{{ else }} + {{ $query = first $items_count $query }} +{{ end }} + {{ $count := len $query }} {{/* Localisation */}} diff --git a/layouts/partials/widgets/publications_featured.html b/layouts/partials/widgets/publications_featured.html deleted file mode 100644 index 994cfcf1..00000000 --- a/layouts/partials/widgets/publications_featured.html +++ /dev/null @@ -1,33 +0,0 @@ -{{ $ := .root }} -{{ $page := .page }} - - -
-
-

{{ with $page.Title }}{{ . | markdownify }}{{ end }}

- {{ with $page.Params.subtitle }}

{{ . | markdownify }}

{{ end }} -
-
- {{ with $page.Content }}

{{ . | markdownify }}

{{ end }} - - {{ if and ($page.Params.publication_type) (ne $page.Params.publication_type "-1") }} - {{ $.Scratch.Set "sel_pubs" (where (where (where $.Site.RegularPages "Type" "publication") ".Params.featured" true) ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }} - {{ else }} - {{ $.Scratch.Set "sel_pubs" (where (where $.Site.RegularPages "Type" "publication") ".Params.featured" true) }} - {{ end }} - - {{ $sel_pubs := $.Scratch.Get "sel_pubs" }} - {{ range $sel_pubs }} - {{ if eq $page.Params.view 1 }} - {{ partial "li_list" . }} - {{ else if eq $page.Params.view 3 }} - {{ partial "li_card" . }} - {{ else if eq $page.Params.view 4 }} - {{ partial "li_citation" . }} - {{ else }} - {{ partial "li_compact" . }} - {{ end }} - {{ end }} - -
-
diff --git a/layouts/partials/widgets/talks_featured.html b/layouts/partials/widgets/talks_featured.html deleted file mode 100644 index 4075c6d4..00000000 --- a/layouts/partials/widgets/talks_featured.html +++ /dev/null @@ -1,23 +0,0 @@ -{{ $ := .root }} -{{ $page := .page }} - - -
-
-

{{ with $page.Title }}{{ . | markdownify }}{{ end }}

- {{ with $page.Params.subtitle }}

{{ . | markdownify }}

{{ end }} -
-
- {{ with $page.Content }}

{{ . | markdownify }}

{{ end }} - - {{ range (sort (where (where $.Site.RegularPages "Type" "talk") ".Params.featured" true) ".Params.time_start" "desc") }} - {{ if eq $page.Params.view 1 }} - {{ partial "li_list" . }} - {{ else if eq $page.Params.view 3 }} - {{ partial "li_card" . }} - {{ else }} - {{ partial "li_compact" . }} - {{ end }} - {{ end }} -
-