docs/.vitepress/theme/index.ts

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

122 lines · 3825 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.scss'
 12import { NolebaseGitChangelogPlugin } from '@nolebase/vitepress-plugin-git-changelog/client'
 13import { NolebasePagePropertiesPlugin } from '@nolebase/vitepress-plugin-page-properties/client'
 14import FloatingVue from 'floating-vue'
 15import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/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 Authors from './components/Authors.vue'
 21import Tooltip from './components/Tooltip.vue'
 22import { createMediumZoomProvider } from './composables/medium-zoom'
 23import 'virtual:uno.css'
 24import Feedback from './components/Feedback.vue'
 25import Layout from './Layout.vue'
 26import './styles/tooltip-hint.css'
 27import './styles/steps.css'
 28import Block from './components/Block.vue'
 29import LinkInline from './components/LinkInline.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('Block', Block)
 53    app.component('Authors', Authors)
 54    app.component('Tooltip', Tooltip)
 55    app.component('Feedback', Feedback)
 56    createMediumZoomProvider(app, router)
 57    // @ts-expect-error
 58    app.use(NolebaseGitChangelogPlugin, {
 59      commitsRelativeTime: true,
 60      hideChangelogHeader: true,
 61      mapAuthors: [
 62        {
 63          name: 'taskylizard',
 64          username: 'taskylizard',
 65          avatar: 'https://github.com/taskylizard.png'
 66        },
 67        {
 68          name: 'Duck',
 69          username: 'woducku',
 70          avatar: 'https://github.com/woducku.png'
 71        }
 72      ]
 73    })
 74    app.use(
 75      NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(),
 76      [
 77        {
 78          locales: {
 79            en: [
 80              {
 81                key: 'tags',
 82                type: 'tags',
 83                title: 'Tags'
 84              },
 85              {
 86                key: 'createdAt',
 87                type: 'datetime',
 88                title: 'Created at',
 89                formatAsFrom: true,
 90                dateFnsLocaleName: 'enUS'
 91              },
 92              {
 93                key: 'updatedAt',
 94                type: 'datetime',
 95                title: 'Updated at',
 96                formatAsFrom: true,
 97                dateFnsLocaleName: 'enUS'
 98              },
 99              {
100                key: 'wordsCount',
101                type: 'dynamic',
102                title: 'Word count',
103                options: {
104                  type: 'wordsCount'
105                }
106              },
107              {
108                key: 'readingTime',
109                type: 'dynamic',
110                title: 'Reading time',
111                options: {
112                  type: 'readingTime',
113                  dateFnsLocaleName: 'enUS'
114                }
115              }
116            ]
117          }
118        }
119      ]
120    )
121  }
122} satisfies Theme