Skip to content

Commit 95c9dcf

Browse files
committed
update
1 parent 37e0db0 commit 95c9dcf

File tree

9 files changed

+10746
-16
lines changed

9 files changed

+10746
-16
lines changed

package-lock.json

Lines changed: 10642 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@astrojs/check": "^0.9.4",
2222
"@astrojs/rss": "^4.0.11",
2323
"@astrojs/vercel": "^8.1.3",
24+
"@giscus/react": "^3.1.0",
2425
"@playform/compress": "^0.1.9",
2526
"@unocss/reset": "^65.5.0",
2627
"@waline/client": "^3.5.6",

packages/pure/components/pages/PageInfo.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ const path = Astro.url.pathname
77
---
88

99
<div class={cn('text-base text-sm text-muted-foreground', className)} {...props}>
10-
<span class='waline-pageview-count' data-path={path}></span> views
1110
{
1211
!hideComment && (
13-
<a href='#waline'>
14-
| <span class='waline-comment-count' data-path={path} /> comments
12+
<a href='#giscus-container'>
13+
View comments
1514
</a>
1615
)
1716
}

packages/pure/types/integrations-config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,30 @@ export const IntegrationConfigSchema = () =>
5252
emoji: z.array(z.string()).optional(),
5353
/** Additional configurations for the Waline comment system. */
5454
additionalConfigs: z.record(z.string(), z.any()).default({})
55+
}),
56+
57+
/** The Giscus comment system */
58+
giscus: z.object({
59+
/** Enable the Giscus comment system. */
60+
enable: z.boolean().default(false),
61+
/** The GitHub repository to use for comments. */
62+
repo: z.string(),
63+
/** The repository ID. */
64+
repoId: z.string(),
65+
/** The discussion category name. */
66+
category: z.string(),
67+
/** The discussion category ID. */
68+
categoryId: z.string(),
69+
/** The mapping between the current page and GitHub discussion. */
70+
mapping: z.string().default('pathname'),
71+
/** Whether to enable reactions for the comments. */
72+
reactionsEnabled: z.string().default('1'),
73+
/** Whether the metadata should be sent to the parent window. */
74+
emitMetadata: z.string().default('0'),
75+
/** Where the comment box should be placed. */
76+
inputPosition: z.string().default('top'),
77+
/** The language Giscus should use. */
78+
lang: z.string().default('en')
5579
})
5680
})
5781

src/components/GiscusComment.astro

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
import config from '../site.config'
3+
4+
const { class: className } = Astro.props
5+
---
6+
7+
{
8+
config.integ.giscus.enable && (
9+
<div id="giscus-container" class={className}></div>
10+
)
11+
}
12+
13+
<script>
14+
import config from '../site.config'
15+
16+
// Only load if giscus is enabled
17+
if (config.integ.giscus?.enable) {
18+
const giscusConfig = config.integ.giscus;
19+
20+
// Create script element
21+
const script = document.createElement('script');
22+
script.src = "https://giscus.app/client.js";
23+
script.setAttribute("data-repo", giscusConfig.repo);
24+
script.setAttribute("data-repo-id", giscusConfig.repoId);
25+
script.setAttribute("data-category", giscusConfig.category);
26+
script.setAttribute("data-category-id", giscusConfig.categoryId);
27+
script.setAttribute("data-mapping", giscusConfig.mapping);
28+
script.setAttribute("data-strict", "0");
29+
script.setAttribute("data-reactions-enabled", giscusConfig.reactionsEnabled);
30+
script.setAttribute("data-emit-metadata", giscusConfig.emitMetadata);
31+
script.setAttribute("data-input-position", giscusConfig.inputPosition);
32+
script.setAttribute("data-theme", document.documentElement.classList.contains('dark') ? 'dark' : 'light');
33+
script.setAttribute("data-lang", giscusConfig.lang);
34+
script.setAttribute("data-loading", "lazy");
35+
script.setAttribute("crossorigin", "anonymous");
36+
script.async = true;
37+
38+
// Add script to container
39+
const container = document.getElementById('giscus-container');
40+
if (container) {
41+
container.appendChild(script);
42+
}
43+
}
44+
</script>

src/layouts/BlogPost.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import type { CollectionEntry } from 'astro:content'
55
// Plugin styles
66
import 'katex/dist/katex.min.css'
77
8-
import { Comment, MediumZoom } from 'astro-pure/advanced'
8+
import { MediumZoom } from 'astro-pure/advanced'
99
import { ArticleBottom, Copyright, Hero, TOC } from 'astro-pure/components/pages'
1010
import PageLayout from '@/layouts/ContentLayout.astro'
1111
import { integ } from '@/site-config'
12+
import GiscusComment from '@/components/GiscusComment.astro'
1213
1314
interface Props {
1415
post: CollectionEntry<'blog'>
@@ -60,7 +61,7 @@ const primaryColor = data.heroImage?.color ?? 'hsl(var(--primary) / var(--un-tex
6061
{/* Article recommend */}
6162
<ArticleBottom collections={posts} {id} class='mt-3 sm:mt-6' />
6263
{/* Comment */}
63-
{!isDraft && enableComment && <Comment class='mt-3 sm:mt-6' />}
64+
{!isDraft && enableComment && <GiscusComment class='mt-3 sm:mt-6' />}
6465
</Fragment>
6566

6667
<slot name='bottom-sidebar' slot='bottom-sidebar' />

src/pages/about/index.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
import { Image } from 'astro:assets'
3-
import { Comment } from 'astro-pure/advanced'
4-
import { Button, Collapse, Spoiler, Timeline } from 'astro-pure/user'
3+
import { Spoiler, Timeline, Button, Collapse } from 'astro-pure/user'
54
import PageLayout from '@/layouts/CommonPage.astro'
65
import Substats from '@/components/about/Substats.astro'
76
import ToolSection from '@/components/about/ToolSection.astro'
7+
import GiscusComment from '@/components/GiscusComment.astro'
88
99
import avatar from '@/assets/avatar.png'
1010
import github from '@/assets/icons/social/github.svg'
@@ -147,7 +147,7 @@ const headings = [
147147
<li>
148148
Site hosting: <a href='https://github.com/Lexciese/lexciese.github.io' target='_blank'>GitHub Pages</a>
149149
</li>
150-
<li>Comment system: <a href='https://waline.js.org' target='_blank'>Waline</a></li>
150+
<li>Comment system: <a href='https://giscus.app/' target='_blank'>Giscus</a></li>
151151
</ul>
152-
<Comment slot='bottom' />
152+
<GiscusComment slot='bottom' />
153153
</PageLayout>

src/pages/links/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import links from 'public/links.json'
33
import config from 'virtual:config'
44
5-
import { Comment } from 'astro-pure/advanced'
65
import { Collapse, Timeline } from 'astro-pure/user'
76
import PageLayout from '@/layouts/CommonPage.astro'
87
import FriendList from '@/components/links/FriendList.astro'
8+
import GiscusComment from '@/components/GiscusComment.astro'
99
1010
const headings = [
1111
{ depth: 2, slug: 'professional', text: 'Professional' },
@@ -90,5 +90,5 @@ const linksConf = config.integ.links
9090
}
9191
</blockquote>
9292

93-
<Comment slot='bottom' />
93+
<GiscusComment slot='bottom' />
9494
</PageLayout>

src/site.config.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ export const integ: IntegrationUserConfig = {
9595
applyTip: [
9696
{ name: 'Name', val: theme.title },
9797
{ name: 'Desc', val: theme.description || 'Null' },
98-
{ name: 'Link', val: 'https://astro-pure.js.org/' },
99-
{ name: 'Avatar', val: 'https://astro-pure.js.org/favicon/favicon.ico' }
98+
{ name: 'Link', val: 'lexciese.github.io' },
10099
]
101100
},
102101
// Enable page search function
@@ -128,9 +127,14 @@ export const integ: IntegrationUserConfig = {
128127
},
129128
// Comment system
130129
waline: {
131-
enable: true,
132-
// Server service link
133-
server: 'https://astro-theme-pure-waline.arthals.ink/',
130+
enable: false, // Disabled - not suitable for static sites on GitHub Pages
131+
// Server service link - you need to set up your own Waline server
132+
// Follow the guide at https://waline.js.org/en/guide/get-started.html
133+
// Quick deploy options:
134+
// - Vercel: https://waline.js.org/en/guide/get-started.html#vercel-deploy
135+
// - Netlify: https://waline.js.org/en/guide/get-started.html#netlify-deploy
136+
// After deployment, replace this URL with your own Waline server URL
137+
server: '',
134138
// Refer https://waline.js.org/en/guide/features/emoji.html
135139
emoji: ['bmoji', 'weibo'],
136140
// Refer https://waline.js.org/en/reference/client/props.html
@@ -144,6 +148,21 @@ export const integ: IntegrationUserConfig = {
144148
},
145149
imageUploader: false
146150
}
151+
},
152+
// Giscus comment system - uses GitHub Discussions as backend
153+
// Learn more and get your settings at https://giscus.app/
154+
giscus: {
155+
enable: true,
156+
// Fill in the following values from https://giscus.app/
157+
repo: 'Lexciese/lexciese.github.io',
158+
repoId: 'R_kgDOOYZ11g',
159+
category: 'Q&A',
160+
categoryId: 'DIC_kwDOOYZ11s4CpC8b',
161+
mapping: 'pathname',
162+
reactionsEnabled: '1',
163+
emitMetadata: '0',
164+
inputPosition: 'bottom',
165+
lang: 'en'
147166
}
148167
}
149168

0 commit comments

Comments
 (0)