From 399e503647b8ab0d436412c9fdba3c29beed7688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Thu, 21 May 2020 10:56:05 +0200 Subject: [PATCH] Allow slides and recordings be linked to talks --- archetypes/talks.md | 4 ++++ themes/patek/i18n/cs.toml | 8 +++++++ themes/patek/i18n/en.toml | 7 ++++++ .../patek/layouts/partials/linkedContent.html | 23 +++++++++++++++++++ .../layouts/partials/talksPageHeader.html | 2 ++ 5 files changed, 44 insertions(+) create mode 100644 themes/patek/layouts/partials/linkedContent.html diff --git a/archetypes/talks.md b/archetypes/talks.md index 232182b..e2b85b2 100644 --- a/archetypes/talks.md +++ b/archetypes/talks.md @@ -4,4 +4,8 @@ date: {{ .Date }} draft: false authors: [ "unknown" ] when: {{ .Date }} +slides: + - data: +recordings: + - data: --- \ No newline at end of file diff --git a/themes/patek/i18n/cs.toml b/themes/patek/i18n/cs.toml index 7dd23b0..82160e8 100644 --- a/themes/patek/i18n/cs.toml +++ b/themes/patek/i18n/cs.toml @@ -32,6 +32,14 @@ other = "Datum přednášky" [talks-paginator-heading] other = "Nadcházející a proběhlé Talky" +[talks-slides] +other = "Prezentace" + +[talks-recording] +one = "Záznam" +few = "Záznamy" +other = "Záznamy" + [tags] other = "Tagy" diff --git a/themes/patek/i18n/en.toml b/themes/patek/i18n/en.toml index edb55e0..18b081a 100644 --- a/themes/patek/i18n/en.toml +++ b/themes/patek/i18n/en.toml @@ -27,6 +27,13 @@ other = "Speaker" [talks-paginator-heading] other = "Upcoming and past Talks" +[talks-slides] +other = "Slides" + +[talks-recording] +one = "Recording" +other = "Recordings" + [tags] other = "Tags" diff --git a/themes/patek/layouts/partials/linkedContent.html b/themes/patek/layouts/partials/linkedContent.html new file mode 100644 index 0000000..0ecf245 --- /dev/null +++ b/themes/patek/layouts/partials/linkedContent.html @@ -0,0 +1,23 @@ +{{- range $i, $_ := .content -}} + {{- $type := (default "link" .type) -}} + {{- $desc := .desc -}} + {{- if (eq (len $.content) 1) -}} + {{- $desc = (default $.text $desc) -}} + {{- else -}} + {{- if (and (not (isset . "desc")) (not (eq $type "text"))) -}}{{- errorf "Missing description for content %s" .data -}}{{- end -}} + {{- end -}} + + {{- if (and (or (gt (len $.content) 1) (eq $type "text")) (eq $i 0)) -}}{{- $.text -}}: {{- end -}} + {{- if (gt $i 0) -}}, {{ end -}} + + {{- if (eq $type "link") -}} + {{ $desc }} + {{- else if (eq $type "text") -}} + {{- .data -}} + {{- else if (eq $type "resource") -}} + {{- $resource := $.resources.GetMatch "fablab-experience.jpg" -}} + {{ $desc }} + {{- else -}} + {{- errorf "Unknown content type %s" $type -}} + {{- end -}} +{{- end -}} diff --git a/themes/patek/layouts/partials/talksPageHeader.html b/themes/patek/layouts/partials/talksPageHeader.html index 0bbd359..37ca12f 100644 --- a/themes/patek/layouts/partials/talksPageHeader.html +++ b/themes/patek/layouts/partials/talksPageHeader.html @@ -5,4 +5,6 @@

{{- T "presenter" -}}: {{ range .Params.authors }}{{ with $.Site.GetPage (printf "authors/%s" .) }}{{ .Title }}{{ end }}{{ end }}

+ {{- with .Params.slides -}}

{{ partial "linkedContent" (dict "text" (T "talks-slides" (len .)) "content" . "resources" $.Page.Resources) }}

{{- end -}} + {{- with .Params.recordings -}}

{{ partial "linkedContent" (dict "text" (T "talks-recording" (len .)) "content" . "resources" $.Page.Resources) }}

{{- end -}}