From 6b7202c7bcb59f709af8bdad5c4a669a7cc3f0a8 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Tue, 31 Oct 2017 20:25:05 +0000 Subject: [PATCH] Display tags (if set) for all content types Close #363 --- archetypes/publication.md | 4 +++ archetypes/talk.md | 4 +++ layouts/_default/single.html | 24 +++++-------- layouts/partials/tags.html | 10 ++++++ layouts/project/single.html | 60 +++++++++++++++++---------------- layouts/publication/single.html | 2 ++ layouts/talk/single.html | 2 ++ 7 files changed, 62 insertions(+), 44 deletions(-) create mode 100644 layouts/partials/tags.html diff --git a/archetypes/publication.md b/archetypes/publication.md index bd15f90b..b1dfc4ca 100644 --- a/archetypes/publication.md +++ b/archetypes/publication.md @@ -37,6 +37,10 @@ selected = false # E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`. projects = [] +# Tags (optional). +# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. +tags = [] + # Links (optional). url_pdf = "" url_preprint = "" diff --git a/archetypes/talk.md b/archetypes/talk.md index 1eba0fca..c3104672 100644 --- a/archetypes/talk.md +++ b/archetypes/talk.md @@ -28,6 +28,10 @@ selected = false # E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`. projects = [] +# Tags (optional). +# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. +tags = [] + # Links (optional). url_pdf = "" url_slides = "" diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 596bfd0e..a628db23 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -6,23 +6,17 @@ {{ partial "header_image.html" . }}
-

{{ .Title }}

- {{ partial "article_metadata" (dict "content" . "is_list" 0) }} -
- {{ .Content }} -
+
+

{{ .Title }}

- {{ if isset $.Params "tags" }} - {{ $tagsLen := len $.Params.tags }} - {{ if gt $tagsLen 0 }} - - {{ end }} - {{ end }} + {{ partial "article_metadata" (dict "content" . "is_list" 0) }} +
+ {{ .Content }} +
+ + {{ partial "tags.html" . }} +
diff --git a/layouts/partials/tags.html b/layouts/partials/tags.html new file mode 100644 index 00000000..989d8492 --- /dev/null +++ b/layouts/partials/tags.html @@ -0,0 +1,10 @@ +{{ if isset $.Params "tags" }} +{{ $tagsLen := len $.Params.tags }} +{{ if gt $tagsLen 0 }} +
+ {{ range $k, $v := $.Params.tags }} + {{ . }} + {{ end }} +
+{{ end }} +{{ end }} diff --git a/layouts/project/single.html b/layouts/project/single.html index 91a7a666..e9c6eb11 100644 --- a/layouts/project/single.html +++ b/layouts/project/single.html @@ -21,42 +21,44 @@
{{ .Content }} +
- {{ $page := . }} - {{ $project := .File.TranslationBaseName }} - {{ $project_path := printf "%s/%s/" .Section $project }} + {{ partial "tags.html" . }} - {{ if (.Site.Params.projects.list_children | default true) }} - {{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }} - {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }} - {{ $pubs_len := len $items }} - {{ if ge $pubs_len 1 }} -

{{ (i18n "publications") }}

- {{ range $items }} - {{ if eq $page.Site.Params.projects.publication_format 1 }} - {{ partial "publication_li_detailed" . }} - {{ else if eq $page.Site.Params.projects.publication_format 2 }} - {{ partial "publication_li_apa" . }} - {{ else if eq $page.Site.Params.projects.publication_format 3 }} - {{ partial "publication_li_mla" . }} - {{ else }} - {{ partial "publication_li_simple" . }} - {{ end }} - {{ end }} - {{ end }} + {{ $page := . }} + {{ $project := .File.TranslationBaseName }} + {{ $project_path := printf "%s/%s/" .Section $project }} - {{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }} - {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }} - {{ $talks_len := len $items }} - {{ if ge $talks_len 1 }} -

{{ (i18n "talks") }}

- {{ range $items }} - {{ partial "talk_li_simple" . }} + {{ if (.Site.Params.projects.list_children | default true) }} + {{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }} + {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }} + {{ $pubs_len := len $items }} + {{ if ge $pubs_len 1 }} +

{{ (i18n "publications") }}

+ {{ range $items }} + {{ if eq $page.Site.Params.projects.publication_format 1 }} + {{ partial "publication_li_detailed" . }} + {{ else if eq $page.Site.Params.projects.publication_format 2 }} + {{ partial "publication_li_apa" . }} + {{ else if eq $page.Site.Params.projects.publication_format 3 }} + {{ partial "publication_li_mla" . }} + {{ else }} + {{ partial "publication_li_simple" . }} {{ end }} {{ end }} {{ end }} - + {{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }} + {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }} + {{ $talks_len := len $items }} + {{ if ge $talks_len 1 }} +

{{ (i18n "talks") }}

+ {{ range $items }} + {{ partial "talk_li_simple" . }} + {{ end }} + {{ end }} + {{ end }} + diff --git a/layouts/publication/single.html b/layouts/publication/single.html index 2fbf92a9..d0305616 100644 --- a/layouts/publication/single.html +++ b/layouts/publication/single.html @@ -91,6 +91,8 @@
{{ .Content }}
+ {{ partial "tags.html" . }} + diff --git a/layouts/talk/single.html b/layouts/talk/single.html index 92cc3176..326b9c25 100644 --- a/layouts/talk/single.html +++ b/layouts/talk/single.html @@ -102,6 +102,8 @@ {{ .Content }} + {{ partial "tags.html" . }} +