docs/.vitepress/theme/index.ts
108 lines · 3450 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 './styles/style.scss'
11import { NolebasePagePropertiesPlugin } from '@nolebase/vitepress-plugin-page-properties/client'
12import FloatingVue from 'floating-vue'
13import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
14import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'
15import '@nolebase/vitepress-plugin-page-properties/client/style.css'
16import 'floating-vue/dist/style.css'
17import Authors from './components/Authors.vue'
18import Tooltip from './components/Tooltip.vue'
19import { createMediumZoomProvider } from './composables/medium-zoom'
20import 'virtual:uno.css'
21import Feedback from './components/Feedback.vue'
22import Collapsible from './components/Collapsible.vue'
23import ScrapeTable from './components/ScrapeTable.vue'
24import Layout from './Layout.vue'
25import './styles/tooltip-hint.css'
26import './styles/steps.css'
27import Block from './components/Block.vue'
28import LinkInline from './components/LinkInline.vue'
29import Highlight from './components/Highlight.vue'
30
31export default {
32 extends: DefaultTheme,
33 Layout: Layout,
34 enhanceApp({ app, router }) {
35 app.use(FloatingVue, {
36 themes: {
37 hint: {
38 $extend: 'tooltip',
39 delay: { show: 0, hide: 0 },
40 html: true
41 },
42 'vp-tooltip': {
43 $extend: 'tooltip',
44 $resetCss: true,
45 triggers: ['click', 'touch'],
46 autoHide: true
47 }
48 }
49 })
50 enhanceAppWithTabs(app)
51 app.component('LinkInline', LinkInline)
52 app.component('hl', Highlight)
53 app.component('Block', Block)
54 app.component('Authors', Authors)
55 app.component('Tooltip', Tooltip)
56 app.component('Feedback', Feedback)
57 app.component('Collapsible', Collapsible)
58 app.component('ScrapeTable', ScrapeTable)
59 createMediumZoomProvider(app, router)
60 app.use(
61 NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(),
62 [
63 {
64 locales: {
65 en: [
66 {
67 key: 'tags',
68 type: 'tags',
69 title: 'Tags'
70 },
71 {
72 key: 'createdAt',
73 type: 'datetime',
74 title: 'Created at',
75 formatAsFrom: true,
76 dateFnsLocaleName: 'enUS'
77 },
78 {
79 key: 'updatedAt',
80 type: 'datetime',
81 title: 'Updated at',
82 formatAsFrom: true,
83 dateFnsLocaleName: 'enUS'
84 },
85 {
86 key: 'wordsCount',
87 type: 'dynamic',
88 title: 'Word count',
89 options: {
90 type: 'wordsCount'
91 }
92 },
93 {
94 key: 'readingTime',
95 type: 'dynamic',
96 title: 'Reading time',
97 options: {
98 type: 'readingTime',
99 dateFnsLocaleName: 'enUS'
100 }
101 }
102 ]
103 }
104 }
105 ]
106 )
107 }
108} satisfies Theme