Skip to content

Commit 380a2ab

Browse files
committed
feat: add comments
1 parent d1d0113 commit 380a2ab

4 files changed

Lines changed: 56 additions & 6 deletions

File tree

.vitepress/theme/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// https://vitepress.dev/guide/custom-theme
2-
import { h } from 'vue'
32
import Theme from 'vitepress/theme'
3+
import MyLayout from './layout/MyLayout.vue'
44
import './style.css'
55

66
export default {
77
extends: Theme,
8-
Layout: () => {
9-
return h(Theme.Layout, null, {
10-
// https://vitepress.dev/guide/extending-default-theme#layout-slots
11-
})
12-
},
8+
Layout: MyLayout,
139
enhanceApp({ app, router, siteData }) {
1410
// ...
1511
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script setup lang="ts">
2+
import { useData } from 'vitepress'
3+
import { watchEffect } from 'vue'
4+
5+
const { title, isDark } = useData()
6+
let darkTheme = isDark.value ? 'dark' : 'light'
7+
8+
watchEffect(() => {
9+
darkTheme = isDark.value ? 'dark' : 'light'
10+
})
11+
12+
</script>
13+
14+
<template>
15+
<div class="layout-comments">
16+
<component
17+
:is="'script'"
18+
:key="title"
19+
src="https://giscus.app/client.js"
20+
data-repo="guangzhengli/k8s-tutorials"
21+
data-repo-id="R_kgDOHS_wpg"
22+
data-category="General"
23+
data-category-id="DIC_kwDOHS_wps4CRGNY"
24+
data-mapping="pathname"
25+
data-strict="0"
26+
data-reactions-enabled="1"
27+
data-emit-metadata="0"
28+
data-input-position="bottom"
29+
:data-theme="darkTheme"
30+
data-lang="en"
31+
data-loading="lazy"
32+
crossorigin="anonymous"
33+
async
34+
/>
35+
</div>
36+
</template>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup lang="ts">
2+
import DefaultTheme from 'vitepress/theme'
3+
import Comments from './Comments.vue'
4+
5+
const { Layout } = DefaultTheme
6+
</script>
7+
8+
<template>
9+
<Layout>
10+
<template #doc-after>
11+
<Comments />
12+
</template>
13+
</Layout>
14+
</template>

.vitepress/theme/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@
8989
--docsearch-primary-color: var(--vp-c-brand) !important;
9090
}
9191

92+
.layout-comments {
93+
margin-top: 2rem;
94+
}
95+

0 commit comments

Comments
 (0)