docs/.vitepress/theme/index.ts

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

110 lines · 3504 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 Fb from './components/Fb.vue'
 22import Feedback from './components/Feedback.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 Highlight from './components/Highlight.vue'
 29import LinkInline from './components/LinkInline.vue'
 30import { enhanceAppWithTabs } from './components/tabs'
 31
 32export default {
 33  extends: DefaultTheme,
 34  Layout: Layout,
 35  enhanceApp({ app, router }) {
 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('LinkInline', LinkInline)
 53    app.component('hl', Highlight)
 54    app.component('Block', Block)
 55    app.component('Authors', Authors)
 56    app.component('Tooltip', Tooltip)
 57    app.component('Feedback', Feedback)
 58    app.component('fb', Fb)
 59    app.component('Collapsible', Collapsible)
 60    app.component('ScrapeTable', ScrapeTable)
 61    createMediumZoomProvider(app, router)
 62    app.use(
 63      NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(),
 64      [
 65        {
 66          locales: {
 67            en: [
 68              {
 69                key: 'tags',
 70                type: 'tags',
 71                title: 'Tags'
 72              },
 73              {
 74                key: 'createdAt',
 75                type: 'datetime',
 76                title: 'Created at',
 77                formatAsFrom: true,
 78                dateFnsLocaleName: 'enUS'
 79              },
 80              {
 81                key: 'updatedAt',
 82                type: 'datetime',
 83                title: 'Updated at',
 84                formatAsFrom: true,
 85                dateFnsLocaleName: 'enUS'
 86              },
 87              {
 88                key: 'wordsCount',
 89                type: 'dynamic',
 90                title: 'Word count',
 91                options: {
 92                  type: 'wordsCount'
 93                }
 94              },
 95              {
 96                key: 'readingTime',
 97                type: 'dynamic',
 98                title: 'Reading time',
 99                options: {
100                  type: 'readingTime',
101                  dateFnsLocaleName: 'enUS'
102                }
103              }
104            ]
105          }
106        }
107      ]
108    )
109  }
110} satisfies Theme