Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cai <jimmehcai@gmail.com>2020-09-12 00:00:19 +0300
committerJimmy Cai <jimmehcai@gmail.com>2020-09-12 00:00:19 +0300
commit5265af0b3bac005de6d7cd9c5dfb97fc60ff09f5 (patch)
treea21d2e52b17c8348ee1d1a1071d6cdafd8dd2d4e
parent6f5ee1bbdbca5254a12d9f09fe87ac29854a9b81 (diff)
reafctor(head): rewrite description.html function
-rw-r--r--layouts/partials/data/description.html23
-rw-r--r--layouts/partials/head/head.html9
-rw-r--r--layouts/partials/head/opengraph/provider/base.html7
-rw-r--r--layouts/partials/head/opengraph/provider/twitter.html7
4 files changed, 28 insertions, 18 deletions
diff --git a/layouts/partials/data/description.html b/layouts/partials/data/description.html
index 5531ab5..fa9f785 100644
--- a/layouts/partials/data/description.html
+++ b/layouts/partials/data/description.html
@@ -1,11 +1,12 @@
-{{- with .Description -}}
- {{- . -}}
-{{- else -}}
- {{- if .IsPage -}}
- {{- .Summary -}}
- {{- else -}}
- {{- with .Site.Params.subtitle -}}
- {{- . -}}
- {{- end -}}
- {{- end -}}
-{{- end -}} \ No newline at end of file
+<!-- Use site subtitle by default -->
+{{ $description := .Site.Params.subtitle }}
+
+{{ if .Description }}
+ <!-- Page description exists -->
+ {{ $description = .Description }}
+{{ else if .IsPage }}
+ <!-- Use page summary -->
+ {{ $description = .Summary }}
+{{ end }}
+
+{{ return ($description | plainify)}} \ No newline at end of file
diff --git a/layouts/partials/head/head.html b/layouts/partials/head/head.html
index eb9cc0f..5ab35dd 100644
--- a/layouts/partials/head/head.html
+++ b/layouts/partials/head/head.html
@@ -1,10 +1,13 @@
<head>
<meta charset='utf-8'>
- <meta name='viewport' content='width=device-width, initial-scale=1'>
- <meta name='description' content='{{ chomp (partial "data/description" . | plainify ) }}'>
+ <meta name='viewport' content='width=device-width, initial-scale=1'>
+
+ {{- $description := partial "data/description" . -}}
+ <meta name='description' content='{{ $description }}'>
{{- $title := partial "data/title" . -}}
- <title>{{ $title }}</title>
+ <title>{{ $title }}</title>
+
<link rel='canonical' href='{{ .Permalink }}'>
{{- partial "head/style.html" . -}}
diff --git a/layouts/partials/head/opengraph/provider/base.html b/layouts/partials/head/opengraph/provider/base.html
index beac56c..ea7f084 100644
--- a/layouts/partials/head/opengraph/provider/base.html
+++ b/layouts/partials/head/opengraph/provider/base.html
@@ -1,5 +1,8 @@
-<meta property='og:title' content='{{ partial "data/title" . }}'>
-<meta property='og:description' content='{{ chomp (partial "data/description" . | plainify ) }}'>
+{{- $title := partial "data/title" . -}}
+{{- $description := partial "data/description" . -}}
+
+<meta property='og:title' content='{{ $title }}'>
+<meta property='og:description' content='{{ $description }}'>
<meta property='og:url' content='{{ .Permalink }}'>
<meta property='og:site_name' content='{{ .Site.Title }}'>
<meta property='og:type' content='
diff --git a/layouts/partials/head/opengraph/provider/twitter.html b/layouts/partials/head/opengraph/provider/twitter.html
index 0495020..707ae2b 100644
--- a/layouts/partials/head/opengraph/provider/twitter.html
+++ b/layouts/partials/head/opengraph/provider/twitter.html
@@ -2,8 +2,11 @@
<meta name="twitter:site" content="{{ . }}">
{{- end -}}
-<meta name="twitter:title" content="{{ partial "data/title" . }}">
-<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}">
+{{- $title := partial "data/title" . -}}
+{{- $description := partial "data/description" . -}}
+
+<meta name="twitter:title" content="{{ $title }}">
+<meta name="twitter:description" content="{{ $description }}">
{{- $image := partial "helper/image" (dict "Context" . "Type" "opengraph") -}}
{{- if $image.exists -}}