docs/.vitepress/theme/index.ts
124 lines · 3983 bytes
1/**
2* All Rights Reserved
3*
4* Copyright (c) 2025 taskylizard
5*
6* All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
7*/
8import type { Theme } from 'vitepress'
9import DefaultTheme from 'vitepress/theme'
10import '@nolebase/vitepress-plugin-git-changelog/client/style.css'
11import './styles/style.css'
12import FloatingVue from 'floating-vue'
13import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
14import { NolebaseGitChangelogPlugin } from '@nolebase/vitepress-plugin-git-changelog/client'
15import { NolebasePagePropertiesPlugin } from '@nolebase/vitepress-plugin-page-properties/client'
16import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'
17import '@nolebase/vitepress-plugin-page-properties/client/style.css'
18import '@nolebase/vitepress-plugin-git-changelog/client/style.css'
19import 'floating-vue/dist/style.css'
20import { createMediumZoomProvider } from './composables/medium-zoom'
21import { createOpProvider } from './composables/op'
22import Button from './components/Button.vue'
23import Tooltip from './components/Tooltip.vue'
24import Authors from './components/Authors.vue'
25import GradientCard from './components/GradientCard.vue'
26import 'virtual:uno.css'
27import Feedback from './components/Feedback.vue'
28import Layout from './Layout.vue'
29import PreferenceRadio from './components/PreferenceRadio.vue'
30import './styles/tooltip-hint.css'
31
32export default {
33 extends: DefaultTheme,
34 Layout: Layout,
35 enhanceApp({ app, router, siteData }) {
36 app.use(FloatingVue, {
37 themes: {
38 hint: {
39 $extend: 'tooltip',
40 delay: { show: 0, hide: 0 },
41 html: true
42 },
43 'vp-tooltip': {
44 $extend: 'tooltip',
45 $resetCss: true,
46 triggers: ['click', 'touch'],
47 autoHide: true
48 }
49 }
50 })
51 enhanceAppWithTabs(app)
52 app.component('Button', Button)
53 app.component('Authors', Authors)
54 app.component('Tooltip', Tooltip)
55 app.component('Feedback', Feedback)
56 app.component('PreferenceRadio', PreferenceRadio)
57 createMediumZoomProvider(app, router)
58 createOpProvider(app)
59 app.component('GradientCard', GradientCard)
60 app.use(NolebaseGitChangelogPlugin, {
61 commitsRelativeTime: true,
62 hideChangelogHeader: true,
63 mapAuthors: [
64 {
65 name: 'taskylizard',
66 username: 'taskylizard',
67 avatar: 'https://github.com/taskylizard.png'
68 },
69 {
70 name: 'Duck',
71 username: 'woducku',
72 avatar: 'https://github.com/woducku.png'
73 }
74 ]
75 })
76 app.use(
77 NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(),
78 [
79 {
80 locales: {
81 en: [
82 {
83 key: 'tags',
84 type: 'tags',
85 title: 'Tags'
86 },
87 {
88 key: 'createdAt',
89 type: 'datetime',
90 title: 'Created at',
91 formatAsFrom: true,
92 dateFnsLocaleName: 'enUS'
93 },
94 {
95 key: 'updatedAt',
96 type: 'datetime',
97 title: 'Updated at',
98 formatAsFrom: true,
99 dateFnsLocaleName: 'enUS'
100 },
101 {
102 key: 'wordsCount',
103 type: 'dynamic',
104 title: 'Word count',
105 options: {
106 type: 'wordsCount'
107 }
108 },
109 {
110 key: 'readingTime',
111 type: 'dynamic',
112 title: 'Reading time',
113 options: {
114 type: 'readingTime',
115 dateFnsLocaleName: 'enUS'
116 }
117 }
118 ]
119 }
120 }
121 ]
122 )
123 }
124} satisfies Theme