From 540dd0328456d2f7d55e799bd5e8c2a0bc50e4e6 Mon Sep 17 00:00:00 2001 From: bravo-kernel Date: Sun, 29 Jan 2023 12:50:55 +0100 Subject: [PATCH] Adds Giscus comments --- .env | 6 ++++++ data/siteMetadata.js | 25 ++++++++++++++++++++++--- layouts/PostSimple.tsx | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..d6aa91c --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +# https://wiki.dendron.so/notes/dgxeztu4fojuo9ulcwlzocu/ +NEXT_PUBLIC_GISCUS_REPO=bravo-kernel/bravo-kernel.com +NEXT_PUBLIC_GISCUS_REPOSITORY_ID=R_kgDOI2pK5g +NEXT_PUBLIC_GISCUS_CATEGORY=Comments +NEXT_PUBLIC_GISCUS_CATEGORY_ID=DIC_kwDOI2pK5s4CT3ll + diff --git a/data/siteMetadata.js b/data/siteMetadata.js index 4fd6fb2..2fe3f0d 100644 --- a/data/siteMetadata.js +++ b/data/siteMetadata.js @@ -35,9 +35,28 @@ const siteMetadata = { // content security policy in the `next.config.js` file. // Select a provider and use the environment variables associated to it // https://vercel.com/docs/environment-variables - provider: 'disqus', // supported providers: giscus, utterances, disqus - disqusConfig: { - shortname: 'bravo-kernel', + provider: 'giscus', // supported providers: giscus, utterances, disqus + giscusConfig: { + // Visit the link below, and follow the steps in the 'configuration' section + // https://giscus.app/ + repo: process.env.NEXT_PUBLIC_GISCUS_REPO, + repositoryId: process.env.NEXT_PUBLIC_GISCUS_REPOSITORY_ID, + category: process.env.NEXT_PUBLIC_GISCUS_CATEGORY, + categoryId: process.env.NEXT_PUBLIC_GISCUS_CATEGORY_ID, + mapping: 'pathname', // supported options: pathname, url, title + reactions: '1', // Emoji reactions: 1 = enable / 0 = disable + // Send discussion metadata periodically to the parent window: 1 = enable / 0 = disable + metadata: '0', + // theme example: light, dark, dark_dimmed, dark_high_contrast + // transparent_dark, preferred_color_scheme, custom + theme: 'light', + // theme when dark mode + darkTheme: 'transparent_dark', + // If the theme option above is set to 'custom` + // please provide a link below to your custom theme css file. + // example: https://giscus.app/themes/custom_example.css + themeURL: '', + lang: 'en', }, }, } diff --git a/layouts/PostSimple.tsx b/layouts/PostSimple.tsx index f86d89c..cd993a8 100644 --- a/layouts/PostSimple.tsx +++ b/layouts/PostSimple.tsx @@ -18,7 +18,7 @@ interface LayoutProps { } export default function PostLayout({ content, next, prev, children }: LayoutProps) { - const [loadComments, setLoadComments] = useState(false) + const [loadComments, setLoadComments] = useState(true) // load comments by default const { path, slug, date, title } = content