From 2f6eea435801afb2cf74ac4e1c6be1d847ae9bcf Mon Sep 17 00:00:00 2001 From: Rohan Deb Sarkar Date: Thu, 18 May 2023 00:01:43 +0530 Subject: [PATCH 1/2] Add support for giscus comments --- exampleSite/config/_default/params.yaml | 18 ++++++++++++++++++ layouts/partials/scripts/giscus.html | 19 +++++++++++++++++++ layouts/partials/scripts/theme.html | 3 ++- layouts/posts/single.html | 6 ++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/scripts/giscus.html diff --git a/exampleSite/config/_default/params.yaml b/exampleSite/config/_default/params.yaml index 36f9027b..ec23b7f2 100644 --- a/exampleSite/config/_default/params.yaml +++ b/exampleSite/config/_default/params.yaml @@ -28,3 +28,21 @@ socialNavbar: true # show social icons on navbar socialHomePage: true # show social icons on the home page colorTheme: blue # choose a theme from `data/themes` folder + +giscusScript: > # Giscus comments for blog posts. Copy paste the script from https://giscus.app/ + diff --git a/layouts/partials/scripts/giscus.html b/layouts/partials/scripts/giscus.html new file mode 100644 index 00000000..a13ba743 --- /dev/null +++ b/layouts/partials/scripts/giscus.html @@ -0,0 +1,19 @@ +{{ safeHTML .Site.Params.giscusScript }} + + + + diff --git a/layouts/partials/scripts/theme.html b/layouts/partials/scripts/theme.html index 7987cc63..a11b0215 100644 --- a/layouts/partials/scripts/theme.html +++ b/layouts/partials/scripts/theme.html @@ -1,7 +1,8 @@ +giscusScript: > + diff --git a/layouts/partials/scripts/giscus.html b/layouts/partials/scripts/giscus.html index a13ba743..8eb9cf30 100644 --- a/layouts/partials/scripts/giscus.html +++ b/layouts/partials/scripts/giscus.html @@ -7,7 +7,7 @@ if (!iframe) return; iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app'); } - + sendMessage({ setConfig: { theme: theme diff --git a/layouts/posts/single.html b/layouts/posts/single.html index b77cdfec..7c3f9bf4 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -52,6 +52,6 @@

{{ if (and .Site.Params.giscusScript (not .Params.disableGiscusComments)) }}
{{ partial "scripts/giscus" . }} -
+ {{ end }} {{ end }}