Skip to content

Commit

Permalink
feat: add giscus
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenKS12138 committed Mar 9, 2024
1 parent a3798c2 commit f528de5
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"preview": "vite preview --port 3333"
},
"dependencies": {
"@giscus/vue": "^3.0.0",
"@vueuse/core": "^9.3.0",
"vue": "^3.2.37",
"vue-router": "^4.1.3"
Expand Down
58 changes: 58 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion src/components/ArticleWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script lang="ts" setup>
import dayjs from 'dayjs'
import Giscus from '@giscus/vue';
const { frontmatter } = defineProps<{
frontmatter: {
coverImage?: string,
Expand All @@ -10,9 +12,19 @@ const { frontmatter } = defineProps<{
}>();
useHead({
title: frontmatter.title
title: frontmatter.title,
meta: [
{
property: 'og:title',
content: frontmatter.title,
}
]
})
const isDark = useDark()
const discusTheme = isDark.value ? 'dark' : 'light';
</script>

<template>
Expand All @@ -22,6 +34,9 @@ useHead({
<div class="mt-2 italic">{{ (frontmatter.tags || []).map(x => `#${x}`).join(' ') }}</div>
</div>
<slot></slot>
<Giscus id="comments" repo="ChenKS12138/ChenKS12138.github.io" repoId="MDEwOlJlcG9zaXRvcnkyNzA4Njc3ODM="
category="Announcements" categoryId="DIC_kwDOECUdR84Cd10_" mapping="og:title" reactionsEnabled="1" emitMetadata="0"
inputPosition="bottom" :theme="discusTheme" lang="zh-CN" loading="lazy" />
<!-- <div class="rounded bg-gray mt-10 p-1 text-white italic indent-md text-lg">
CC BY-SA 3.0协议 。转载请注明出处!
</div> -->
Expand Down

0 comments on commit f528de5

Please sign in to comment.