diff --git a/exampleSite/content/home/publications.md b/exampleSite/content/home/publications.md index b485b73f..8a947f4d 100644 --- a/exampleSite/content/home/publications.md +++ b/exampleSite/content/home/publications.md @@ -21,5 +21,15 @@ count = 10 # 2 = Detailed list_format = 0 +# 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" +++ diff --git a/exampleSite/content/home/publications_selected.md b/exampleSite/content/home/publications_selected.md index 5e27ac88..072e0716 100644 --- a/exampleSite/content/home/publications_selected.md +++ b/exampleSite/content/home/publications_selected.md @@ -19,5 +19,15 @@ weight = 10 # 2 = Detailed list_format = 2 +# 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" +++ diff --git a/layouts/partials/widgets/publications.html b/layouts/partials/widgets/publications.html index f7322229..a37484e1 100644 --- a/layouts/partials/widgets/publications.html +++ b/layouts/partials/widgets/publications.html @@ -19,7 +19,14 @@
{{ . | markdownify }}
{{ end }} - {{ range first $page.Params.count (where $.Data.Pages "Type" "publication") }} + {{ if and ($page.Params.publication_type) (ne $page.Params.publication_type "-1") }} + {{ $.Scratch.Set "recent_pubs" (where (where $.Data.Pages "Type" "publication") ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }} + {{ else }} + {{ $.Scratch.Set "recent_pubs" (where $.Data.Pages "Type" "publication") }} + {{ end }} + + {{ $recent_pubs := $.Scratch.Get "recent_pubs" }} + {{ range first $page.Params.count $recent_pubs }} {{ if eq $page.Params.list_format 1 }} {{ partial "publication_li_classic" . }} {{ else if eq $page.Params.list_format 2 }} diff --git a/layouts/partials/widgets/publications_selected.html b/layouts/partials/widgets/publications_selected.html index 93d25313..42cce398 100644 --- a/layouts/partials/widgets/publications_selected.html +++ b/layouts/partials/widgets/publications_selected.html @@ -10,13 +10,20 @@{{ . | markdownify }}
{{ end }} - {{ range (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }} + {{ if and ($page.Params.publication_type) (ne $page.Params.publication_type "-1") }} + {{ $.Scratch.Set "sel_pubs" (where (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }} + {{ else }} + {{ $.Scratch.Set "sel_pubs" (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }} + {{ end }} + + {{ $sel_pubs := $.Scratch.Get "sel_pubs" }} + {{ range $sel_pubs }} {{ if eq $page.Params.list_format 1 }} {{ partial "publication_li_classic" . }} {{ else if eq $page.Params.list_format 2 }} {{ partial "publication_li_detailed" . }} {{ else }} - {{ partial "publication_li_simple" . }} + {{ partial "publication_li_simple" . }} {{ end }} {{ end }}