mirror of
https://github.com/MCKero6423/fuwari.git
synced 2026-10-02 03:15:35 +00:00
把giscus评论系统改成twikoo
This commit is contained in:
1 parent
676f05d861
commit
beb0b9e640
5 files changed
+61
-16
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
import { commentConfig } from '@/config'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
path: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
...commentConfig.twikoo,
|
||||||
|
el: '#tcomment',
|
||||||
|
path: Astro.props.path,
|
||||||
|
}
|
||||||
|
---
|
||||||
|
|
||||||
|
<div id="tcomment"></div>
|
||||||
|
<script is:inline src="https://cdn.staticfile.org/twikoo/1.6.44/twikoo.all.min.js"></script>
|
||||||
|
<script is:inline define:vars={{ config }}>
|
||||||
|
twikoo.init(config)
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
import type { CollectionEntry } from 'astro:content'
|
||||||
|
import { commentConfig } from '@/config'
|
||||||
|
import Twikoo from './Twikoo.astro'
|
||||||
|
interface Props {
|
||||||
|
post: CollectionEntry<'posts'>
|
||||||
|
}
|
||||||
|
|
||||||
|
const { id, data, slug } = Astro.props.post
|
||||||
|
|
||||||
|
const path = `/posts/${slug}`
|
||||||
|
const url = `${Astro.site?.href}${path}`
|
||||||
|
|
||||||
|
let commentService = ''
|
||||||
|
if (commentConfig?.twikoo) {
|
||||||
|
commentService = 'twikoo'
|
||||||
|
}
|
||||||
|
---
|
||||||
|
<div class="card-base p-6 mb-4">
|
||||||
|
{commentService === 'twikoo' && <Twikoo path={path} />}
|
||||||
|
{commentService === '' && null}
|
||||||
|
</div>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type {
|
import type {
|
||||||
ExpressiveCodeConfig,
|
ExpressiveCodeConfig,
|
||||||
|
CommentConfig,
|
||||||
LicenseConfig,
|
LicenseConfig,
|
||||||
NavBarConfig,
|
NavBarConfig,
|
||||||
ProfileConfig,
|
ProfileConfig,
|
||||||
@@ -99,3 +100,9 @@ export const expressiveCodeConfig: ExpressiveCodeConfig = {
|
|||||||
// Please select a dark theme, as this blog theme currently only supports dark background color
|
// Please select a dark theme, as this blog theme currently only supports dark background color
|
||||||
theme: "github-dark",
|
theme: "github-dark",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const commentConfig: CommentConfig = {
|
||||||
|
twikoo: {
|
||||||
|
envId: 'https://twikoo.mckero.com/',
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import ImageWrapper from "../../components/misc/ImageWrapper.astro";
|
|||||||
import PostMetadata from "../../components/PostMeta.astro";
|
import PostMetadata from "../../components/PostMeta.astro";
|
||||||
import { profileConfig, siteConfig } from "../../config";
|
import { profileConfig, siteConfig } from "../../config";
|
||||||
import { formatDateToYYYYMMDD } from "../../utils/date-utils";
|
import { formatDateToYYYYMMDD } from "../../utils/date-utils";
|
||||||
|
import Comment from "@components/comment/index.astro"
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const blogEntries = await getSortedPosts();
|
const blogEntries = await getSortedPosts();
|
||||||
@@ -108,22 +109,8 @@ const jsonLd = {
|
|||||||
</Markdown>
|
</Markdown>
|
||||||
|
|
||||||
{licenseConfig.enable && <License title={entry.data.title} slug={entry.slug} pubDate={entry.data.published} class="mb-6 rounded-xl license-container onload-animation"></License>}
|
{licenseConfig.enable && <License title={entry.data.title} slug={entry.slug} pubDate={entry.data.published} class="mb-6 rounded-xl license-container onload-animation"></License>}
|
||||||
<script src="https://giscus.app/client.js"
|
|
||||||
data-repo="MCKero6423/chat"
|
<Comment post={entry}></Comment>
|
||||||
data-repo-id="R_kgDOPcjoqA"
|
|
||||||
data-category="Announcements"
|
|
||||||
data-category-id="DIC_kwDOPcjoqM4CuFO_"
|
|
||||||
data-mapping="pathname"
|
|
||||||
data-strict="0"
|
|
||||||
data-reactions-enabled="1"
|
|
||||||
data-emit-metadata="0"
|
|
||||||
data-input-position="top"
|
|
||||||
data-theme="preferred_color_scheme"
|
|
||||||
data-lang="zh-CN"
|
|
||||||
data-loading="lazy"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
async>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -91,6 +91,16 @@ export type LIGHT_DARK_MODE =
|
|||||||
| typeof DARK_MODE
|
| typeof DARK_MODE
|
||||||
| typeof AUTO_MODE;
|
| typeof AUTO_MODE;
|
||||||
|
|
||||||
|
export type CommentConfig = {
|
||||||
|
twikoo?: TwikooConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
type TwikooConfig = {
|
||||||
|
envId: string
|
||||||
|
region?: string
|
||||||
|
lang?: string
|
||||||
|
}
|
||||||
|
|
||||||
export type BlogPostData = {
|
export type BlogPostData = {
|
||||||
body: string;
|
body: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
Reference in new issue
Block a user