Skip to content

Commit 794aee1

Browse files
committed
feat: add custom theme layout
1 parent d9895ae commit 794aee1

File tree

2 files changed

+74
-30
lines changed

2 files changed

+74
-30
lines changed

docs/.vitepress/theme/Layout.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<Layout>
3+
<template #doc-footer-before>
4+
<div
5+
style="
6+
margin-top: 40px;
7+
padding: 2em 0;
8+
text-align: center;
9+
border-top: 1px solid #e2e2e2;
10+
"
11+
>
12+
<table style="margin: 0 auto">
13+
<tbody>
14+
<tr>
15+
<td align="center" style="width: 260px">
16+
<img
17+
src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/images/qrcode-for-doocs.png"
18+
style="width: 200px"
19+
/><br />
20+
</td>
21+
<td align="center" style="width: 260px">
22+
<img
23+
src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/images/qrcode-for-yanglbme.png"
24+
style="width: 200px"
25+
/><br />
26+
</td>
27+
</tr>
28+
</tbody>
29+
</table>
30+
</div>
31+
</template>
32+
</Layout>
33+
</template>
34+
35+
<script setup>
36+
import DefaultTheme from 'vitepress/theme';
37+
const { Layout } = DefaultTheme;
38+
</script>

docs/.vitepress/theme/index.js

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
import DefaultTheme from 'vitepress/theme';
2-
import giscusTalk from 'vitepress-plugin-comment-with-giscus';
3-
import { useData, useRoute } from 'vitepress';
4-
import { toRefs } from "vue";
5-
6-
export default {
7-
...DefaultTheme,
8-
enhanceApp(ctx) {
9-
DefaultTheme.enhanceApp(ctx);
10-
},
11-
setup() {
12-
const { frontmatter } = toRefs(useData());
13-
const route = useRoute();
14-
15-
giscusTalk({
16-
repo: 'doocs/advanced-java',
17-
repoId: 'MDEwOlJlcG9zaXRvcnkxNTE4MzQwNjI=',
18-
mapping: 'number',
19-
inputPosition: 'top',
20-
lang: 'zh-CN',
21-
homePageShowComment: true,
22-
term: '9',
23-
lightTheme: 'light',
24-
darkTheme: 'transparent_dark',
25-
}, {
26-
frontmatter,
27-
route
28-
}, true);
29-
}
30-
};
1+
import DefaultTheme from "vitepress/theme";
2+
import giscusTalk from "vitepress-plugin-comment-with-giscus";
3+
import { useData, useRoute } from "vitepress";
4+
import { toRefs } from "vue";
5+
import Layout from "./Layout.vue";
6+
7+
export default {
8+
extends: DefaultTheme,
9+
Layout: Layout,
10+
enhanceApp(ctx) {
11+
DefaultTheme.enhanceApp(ctx);
12+
},
13+
setup() {
14+
const { frontmatter } = toRefs(useData());
15+
const route = useRoute();
16+
17+
giscusTalk(
18+
{
19+
repo: "doocs/advanced-java",
20+
repoId: "MDEwOlJlcG9zaXRvcnkxNTE4MzQwNjI=",
21+
mapping: "number",
22+
inputPosition: "top",
23+
lang: "zh-CN",
24+
homePageShowComment: true,
25+
term: "9",
26+
lightTheme: "light",
27+
darkTheme: "transparent_dark",
28+
},
29+
{
30+
frontmatter,
31+
route,
32+
},
33+
true
34+
);
35+
},
36+
};

0 commit comments

Comments
 (0)