From 10fefee380f170fbfa3bcb4869da941b407b0d45 Mon Sep 17 00:00:00 2001 From: iGor milhit Date: Fri, 22 May 2020 20:18:25 +0200 Subject: [PATCH] template: add metadata to the html head Expose metadata in a way that Zotero can read, so Dublin Core and Open Graph are an easy way. No so easy, but still. The language attribute of the html tag has been correctly set. In the process, the date test has been improved. Closes #3 Co-Authored-by: Igor Milhit --- layouts/_default/baseof.html | 2 +- layouts/partials/head.html | 1 + layouts/partials/header.html | 1 - layouts/partials/metadata.html | 35 +++++++++++++++++++++++++++++++++ layouts/partials/post-info.html | 5 +---- 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/metadata.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index f1e2252..69f514d 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,5 +1,5 @@ - + {{- partial "head.html" . -}} {{- partial "header.html" . -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index abe664f..c26af0f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -3,6 +3,7 @@ {{ .Title }} | {{ .Site.Title }} + {{- partial "metadata.html" . -}} {{ if .Site.IsServer }} {{ $options := (dict "targetPath" "styles.css" "enableSourceMap" true) }} {{ $styles := resources.Get "scss/main.scss" | toCSS $options }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 37dee05..becbb89 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -14,7 +14,6 @@ {{ if .IsPage }} / rss {{ end }} - diff --git a/layouts/partials/metadata.html b/layouts/partials/metadata.html new file mode 100644 index 0000000..68e44e7 --- /dev/null +++ b/layouts/partials/metadata.html @@ -0,0 +1,35 @@ + + + + + + +{{ if .IsNode }} + +{{ end }} +{{ if .IsPage }} + + + + + {{ if (and (isset .Params "lastmod") (gt (dateFormat "2016-01-02" (.Lastmod)) (dateFormat "2006-01-02" (.PublishDate)))) }} + + {{ end }} + + {{ if (and (isset .Params "lastmod") (gt (dateFormat "2016-01-02" (.Lastmod)) (dateFormat "2006-01-02" (.PublishDate)))) }} + + {{ end }} + {{ with .Params.categories }} + {{ range . }} + + {{ end }} + {{ end }} + {{ with .Params.tags }} + {{ range . }} + + {{ end }} + {{ end }} +{{ end }} diff --git a/layouts/partials/post-info.html b/layouts/partials/post-info.html index e83bb26..89592bf 100644 --- a/layouts/partials/post-info.html +++ b/layouts/partials/post-info.html @@ -1,9 +1,6 @@ -{{ $LastmodFormatted := dateFormat "2006-01-02" (.Lastmod) }} -{{ $PublishdateFormatted := dateFormat "2006-01-02" (.PublishDate) }} -