docs/.vitepress/theme/index.ts

dc37a0812a9971107e75ecfdb141c3d5bf0289fc
wotaku/docs/.vitepress/theme/index.ts history · blame · raw

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