From 361d28797e1b4da76403081cea944ec7a250f98f Mon Sep 17 00:00:00 2001 From: saicaca Date: Thu, 14 Mar 2024 02:15:43 +0800 Subject: [PATCH] feat: add giscus (unfinished) --- src/components/Comment.astro | 35 +++++++++++++++++++++++++++++++++ src/config.ts | 9 +++++++++ src/pages/posts/[...slug].astro | 4 ++++ src/types/config.ts | 8 ++++++++ 4 files changed, 56 insertions(+) create mode 100644 src/components/Comment.astro diff --git a/src/components/Comment.astro b/src/components/Comment.astro new file mode 100644 index 00000000..4ab50900 --- /dev/null +++ b/src/components/Comment.astro @@ -0,0 +1,35 @@ +--- +import {giscusConfig, siteConfig} from "../config"; +interface Props { + postId: string; +} +const { postId } = Astro.props; + +const config = giscusConfig + +const discussionTitle = `giscus - ${postId}` +--- + +{config.enable &&
+
+
} + + + diff --git a/src/config.ts b/src/config.ts index 338190bd..5d049226 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,5 @@ import type { + GiscusConfig, LicenseConfig, NavBarConfig, ProfileConfig, @@ -58,3 +59,11 @@ export const licenseConfig: LicenseConfig = { name: 'CC BY-NC-SA 4.0', url: 'https://creativecommons.org/licenses/by-nc-sa/4.0/', } + +export const giscusConfig: GiscusConfig = { + enable: true, + repo: 'saicaca/f-giscus', + repoId: 'R_kgDOLUcjpw', + category: 'Announcements', + categoryId: 'DIC_kwDOLUcjp84CdVSH', +} \ No newline at end of file diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index 5b657334..11ecb5f5 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -11,6 +11,7 @@ import License from "@components/misc/License.astro"; import {licenseConfig} from "src/config"; import Markdown from "@components/misc/Markdown.astro"; import path from "path"; +import Comment from "@components/Comment.astro"; export async function getStaticPaths() { const blogEntries = await getCollection('posts', ({ data }) => { @@ -109,6 +110,9 @@ const { remarkPluginFrontmatter } = await entry.render(); + + +