From 901d1f63fcf13222a002edff766966a02afb31ae Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sun, 23 Aug 2020 11:30:10 +0200 Subject: [PATCH] refactor(opengraph): move OpenGraph related settings to .Params.opengraph --- exampleSite/config.toml | 6 ++++-- layouts/partials/head/opengraph.html | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 9e50cc0..47c4e73 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -4,17 +4,19 @@ theme = "hugo-theme-stack" paginate = 5 [params] - twitter = "0xJimmy" postSection = "post" emoji = "๐Ÿฅ" avatar = "img/avatar.jpg" - logo = "/avatar.jpg" subtitle = "ๅ’Œไธ–็•Œๅˆ†ไบซๅˆš็ผ–็š„็ ดไบ‹" postLicense = "Licenced under CC BY-NC-SA 4.0" [params.widgets] enabled = ['archive', 'tag-cloud'] [params.widgets.tagCloud] limit = 10 + [params.opengraph] + defaultImage = "img/logo.png" + [params.opengraph.twitter] + site = "0xJimmy" [menu] [[menu.main]] diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph.html index 4e9c368..dd298c2 100644 --- a/layouts/partials/head/opengraph.html +++ b/layouts/partials/head/opengraph.html @@ -10,7 +10,7 @@ {{- end -}} '> -{{ with .Site.Params.twitter }} +{{ with .Site.Params.opengraph.twitter.site }} {{ end }} @@ -40,12 +40,13 @@ {{- end -}} {{- end -}} - - {{- if .Params.image -}} {{ $image := partial "helper/image" . }} + + + +{{- else if .Site.Params.opengraph.defaultImage -}} + {{ $image := resources.Get .Site.Params.opengraph.defaultImage }} -{{- else -}} - {{- end -}} \ No newline at end of file