From 5f7e818b924f321afaf6effbfe07ba0ab27681c4 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 11 Sep 2020 21:55:15 +0200 Subject: [PATCH] refactor(head/opengraph): split code into modules --- exampleSite/config.toml | 1 + layouts/partials/head.html | 2 +- layouts/partials/head/opengraph/include.html | 2 ++ .../{opengraph.html => opengraph/provider/base.html} | 10 +--------- .../partials/head/opengraph/provider/twitter.html | 12 ++++++++++++ 5 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 layouts/partials/head/opengraph/include.html rename layouts/partials/head/{opengraph.html => opengraph/provider/base.html} (73%) create mode 100644 layouts/partials/head/opengraph/provider/twitter.html 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 -}} 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 similarity index 73% rename from layouts/partials/head/opengraph.html rename to 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 }} - -{{ end }} - - - {{- with .Params.locale -}} {{- end -}} @@ -42,7 +36,5 @@ {{ $image := partial "helper/image" (dict "Context" . "Type" "opengraph") }} {{- if $image.exists -}} - - - + {{- 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 -}} + +{{- end -}} + + + + +{{- $image := partial "helper/image" (dict "Context" . "Type" "opengraph") -}} +{{- if $image.exists -}} + + +{{- end -}} \ No newline at end of file