docs/.vitepress/theme/index.ts

434906d314d5ee7327d41535689bca0a29cabdb7
wotaku/docs/.vitepress/theme/index.ts

102 lines · 3163 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 Layout from './Layout.vue'
 23import './styles/tooltip-hint.css'
 24import './styles/steps.css'
 25import Block from './components/Block.vue'
 26import LinkInline from './components/LinkInline.vue'
 27
 28export default {
 29  extends: DefaultTheme,
 30  Layout: Layout,
 31  enhanceApp({ app, router }) {
 32    app.use(FloatingVue, {
 33      themes: {
 34        hint: {
 35          $extend: 'tooltip',
 36          delay: { show: 0, hide: 0 },
 37          html: true
 38        },
 39        'vp-tooltip': {
 40          $extend: 'tooltip',
 41          $resetCss: true,
 42          triggers: ['click', 'touch'],
 43          autoHide: true
 44        }
 45      }
 46    })
 47    enhanceAppWithTabs(app)
 48    app.component('LinkInline', LinkInline)
 49    app.component('Block', Block)
 50    app.component('Authors', Authors)
 51    app.component('Tooltip', Tooltip)
 52    app.component('Feedback', Feedback)
 53    createMediumZoomProvider(app, router)
 54    app.use(
 55      NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(),
 56      [
 57        {
 58          locales: {
 59            en: [
 60              {
 61                key: 'tags',
 62                type: 'tags',
 63                title: 'Tags'
 64              },
 65              {
 66                key: 'createdAt',
 67                type: 'datetime',
 68                title: 'Created at',
 69                formatAsFrom: true,
 70                dateFnsLocaleName: 'enUS'
 71              },
 72              {
 73                key: 'updatedAt',
 74                type: 'datetime',
 75                title: 'Updated at',
 76                formatAsFrom: true,
 77                dateFnsLocaleName: 'enUS'
 78              },
 79              {
 80                key: 'wordsCount',
 81                type: 'dynamic',
 82                title: 'Word count',
 83                options: {
 84                  type: 'wordsCount'
 85                }
 86              },
 87              {
 88                key: 'readingTime',
 89                type: 'dynamic',
 90                title: 'Reading time',
 91                options: {
 92                  type: 'readingTime',
 93                  dateFnsLocaleName: 'enUS'
 94                }
 95              }
 96            ]
 97          }
 98        }
 99      ]
100    )
101  }
102} satisfies Theme