From cfc3f2c8c067d47505e64b1445c4692316fd4eb6 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 16 May 2022 00:33:53 +0200 Subject: Introduce description partial --- layouts/partials/description.html | 15 +++++++++++++++ layouts/partials/head.html | 7 +------ layouts/partials/templates/opengraph.html | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 layouts/partials/description.html diff --git a/layouts/partials/description.html b/layouts/partials/description.html new file mode 100644 index 0000000..e63c0d9 --- /dev/null +++ b/layouts/partials/description.html @@ -0,0 +1,15 @@ +{{- $description := "" -}} + +{{- if .IsHome -}} + {{- $description = site.Params.Description -}} +{{- else -}} + {{- if and (.Params.Description) (ne .Params.Description "") -}} + {{- $description = print .Params.Description -}} + {{- else if and (.Params.Summary ) (ne .Params.Summary "") -}} + {{- $description = print .Params.Summary -}} + {{- else -}} + {{- $description = print .Summary -}} + {{- end -}} +{{- end -}} + +{{- $description | plainify | safeHTML | chomp | truncate 180 -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index abb4cbe..478410a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,10 +1,5 @@ {{/* */}} - {{- $description := print .Params.Description -}} - {{- if or .IsHome (eq .Params.Description "") (not .Params.Description) -}} - {{ $description = site.Params.Description }} - {{- end -}} - @@ -13,7 +8,7 @@ {{ block "title" . }}{{ if .IsHome }}{{ site.Title }}{{ else }}{{ with .Params.Title }}{{ . }} - {{ end }}{{ site.Title }}{{ end }}{{ end }} - + {{ hugo.Generator }} diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html index c94fd68..3b9fb36 100644 --- a/layouts/partials/templates/opengraph.html +++ b/layouts/partials/templates/opengraph.html @@ -1,6 +1,6 @@ - + {{- if .Params.cover.image -}} -- cgit v1.2.3