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-11 22:55:15 +0300
committerJimmy Cai <jimmehcai@gmail.com>2020-09-11 22:55:15 +0300
commit5f7e818b924f321afaf6effbfe07ba0ab27681c4 (patch)
tree3b6c847407944a2dcfb4bcad608288466554cdd1
parent03f91c36b2bc1bd76c53ef3f1af6886dabe48fa6 (diff)
refactor(head/opengraph): split code into modules
-rw-r--r--exampleSite/config.toml1
-rw-r--r--layouts/partials/head.html2
-rw-r--r--layouts/partials/head/opengraph/include.html2
-rw-r--r--layouts/partials/head/opengraph/provider/base.html (renamed from layouts/partials/head/opengraph.html)10
-rw-r--r--layouts/partials/head/opengraph/provider/twitter.html12
5 files changed, 17 insertions, 10 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 496a8ce..e1ae19f 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -40,6 +40,7 @@ DefaultContentLanguage = "en" # Theme i18n support
[params.opengraph]
[params.opengraph.twitter]
site = ""
+ card = "summary_large_image"
[params.defaultImage]
[params.defaultImage.article]
enabled = false
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 98ccd9c..dd51174 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -9,7 +9,7 @@
{{ partial "head/style.html" . }}
{{ partial "head/script.html" . }}
- {{ partial "head/opengraph.html" . }}
+ {{ partial "head/opengraph/include.html" . }}
{{ range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
diff --git a/layouts/partials/head/opengraph/include.html b/layouts/partials/head/opengraph/include.html
new file mode 100644
index 0000000..3a43f48
--- /dev/null
+++ b/layouts/partials/head/opengraph/include.html
@@ -0,0 +1,2 @@
+{{ partial "head/opengraph/provider/base" . }}
+{{ partial "head/opengraph/provider/twitter" . }} \ No newline at end of file
diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph/provider/base.html
index 9410693..beac56c 100644
--- a/layouts/partials/head/opengraph.html
+++ b/layouts/partials/head/opengraph/provider/base.html
@@ -10,12 +10,6 @@
{{- end -}}
'>
-{{ with .Site.Params.opengraph.twitter.site }}
-<meta name="twitter:site" content="{{ . }}">
-{{ end }}
-<meta name="twitter:title" content="{{ partial "data/title" . }}">
-<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}">
-
{{- with .Params.locale -}}
<meta property='og:locale' content='{{ . }}'>
{{- end -}}
@@ -42,7 +36,5 @@
{{ $image := partial "helper/image" (dict "Context" . "Type" "opengraph") }}
{{- if $image.exists -}}
- <meta name="twitter:card" content="summary_large_image">
- <meta property='og:image' content='{{ absURL $image.permalink }}' />
- <meta name="twitter:image" content='{{ absURL $image.permalink }}' />
+ <meta property='og:image' content='{{ absURL $image.permalink }}' />
{{- end -}} \ No newline at end of file
diff --git a/layouts/partials/head/opengraph/provider/twitter.html b/layouts/partials/head/opengraph/provider/twitter.html
new file mode 100644
index 0000000..0495020
--- /dev/null
+++ b/layouts/partials/head/opengraph/provider/twitter.html
@@ -0,0 +1,12 @@
+{{- with .Site.Params.opengraph.twitter.site -}}
+ <meta name="twitter:site" content="{{ . }}">
+{{- end -}}
+
+<meta name="twitter:title" content="{{ partial "data/title" . }}">
+<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}">
+
+{{- $image := partial "helper/image" (dict "Context" . "Type" "opengraph") -}}
+{{- if $image.exists -}}
+ <meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}">
+ <meta name="twitter:image" content='{{ absURL $image.permalink }}' />
+{{- end -}} \ No newline at end of file