Commit 8e0734d08a
8e0734d08aad3940ccc427433ed75f93758bf8d3
parent: e1b98cb57d
Unsigned
Duck <57977673+woducku@users.noreply.github.com> · 2026-05-24 17:28 UTC
Revert "kyu-kurarin"
This reverts commit bcdf0231a5d311dbb499df7f80af82e564c9d25d.
Layout: unified · split
docs/.vitepress/configs/index.ts
+1 −3
| @@ -10,7 +10,6 @@ import { |
| 10 | 10 | PagePropertiesMarkdownSection |
| 11 | 11 | } from '@nolebase/vitepress-plugin-page-properties/vite' |
| 12 | 12 | import { fileURLToPath, URL } from 'node:url' |
| 13 | | import { collectHeadingsPlugin } from '../plugins/collectHeadings' |
| 14 | 13 | import UnoCSS from 'unocss/vite' |
| 15 | 14 | import Devtools from 'vite-plugin-vue-devtools' |
| 16 | 15 | import type { DefaultTheme, Plugin, UserConfig } from 'vitepress' |
| @@ -108,7 +107,6 @@ export const shared: UserConfig<DefaultTheme.Config> = { |
| 108 | 107 | ] |
| 109 | 108 | }, |
| 110 | 109 | plugins: [ |
| 111 | | collectHeadingsPlugin(fileURLToPath(new URL('../../', import.meta.url))), |
| 112 | 110 | Devtools(), |
| 113 | 111 | PageProperties(), |
| 114 | 112 | PagePropertiesMarkdownSection(), |
| @@ -150,4 +148,4 @@ export const shared: UserConfig<DefaultTheme.Config> = { |
| 150 | 148 | ] |
| 151 | 149 | } |
| 152 | 150 | } |
| 153 | | } |
| \ No newline at end of file |
| 151 | } |
docs/.vitepress/plugins/collectHeadings.js
deleted
−48
| @@ -1,48 +0,0 @@ |
| 1 | | import { readdirSync, readFileSync, writeFileSync } from 'fs' |
| 2 | | import { join } from 'path' |
| 3 | | |
| 4 | | export function collectHeadingsPlugin(docsDir) { |
| 5 | | return { |
| 6 | | name: 'collect-h2-headings', |
| 7 | | buildStart() { |
| 8 | | const headings = [] |
| 9 | | collectFromDir(docsDir, docsDir, headings) |
| 10 | | writeFileSync( |
| 11 | | join(docsDir, '.vitepress', 'headings.json'), |
| 12 | | JSON.stringify(headings, null, 2) |
| 13 | | ) |
| 14 | | } |
| 15 | | } |
| 16 | | } |
| 17 | | |
| 18 | | function collectFromDir(baseDir, dir, headings) { |
| 19 | | for (const entry of readdirSync(dir, { withFileTypes: true })) { |
| 20 | | if (entry.isDirectory() && !entry.name.startsWith('.')) { |
| 21 | | collectFromDir(baseDir, join(dir, entry.name), headings) |
| 22 | | } else if (entry.name.endsWith('.md')) { |
| 23 | | const filePath = join(dir, entry.name) |
| 24 | | const content = readFileSync(filePath, 'utf-8') |
| 25 | | const lines = content.split('\n') |
| 26 | | |
| 27 | | // Derive URL path from file path |
| 28 | | let urlPath = filePath |
| 29 | | .replace(baseDir, '') |
| 30 | | .replace(/\\/g, '/') |
| 31 | | .replace(/\.md$/, '') |
| 32 | | .replace(/\/index$/, '/') |
| 33 | | if (!urlPath.startsWith('/')) urlPath = '/' + urlPath |
| 34 | | |
| 35 | | for (const line of lines) { |
| 36 | | const match = line.match(/^##\s+(.+)/) |
| 37 | | if (match) { |
| 38 | | const title = match[1].trim() |
| 39 | | const anchor = '#' + title |
| 40 | | .toLowerCase() |
| 41 | | .replace(/[^\w\s-]/g, '') |
| 42 | | .replace(/\s+/g, '-') |
| 43 | | headings.push({ path: urlPath, anchor, title }) |
| 44 | | } |
| 45 | | } |
| 46 | | } |
| 47 | | } |
| 48 | | } |
| \ No newline at end of file |
docs/.vitepress/theme/components/SidebarCard.vue
+1 −27
| @@ -5,24 +5,8 @@ |
| 5 | 5 | |
| 6 | 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 | 7 | --> |
| 8 | | <script setup> |
| 9 | | import { useRouter } from 'vitepress' |
| 10 | | import headings from '../headings.json' |
| 11 | | |
| 12 | | const router = useRouter() |
| 13 | | |
| 14 | | function goRandom() { |
| 15 | | const pick = headings[Math.floor(Math.random() * headings.length)] |
| 16 | | router.go(pick.path + pick.anchor) |
| 17 | | } |
| 18 | | </script> |
| 19 | | |
| 20 | 8 | <template> |
| 21 | | <div |
| 22 | | class="mt-2 overflow-hidden rounded-lg border-2 border-solid border-$vp-c-default-soft relative z-0 max-md:border max-md:border-neutral-200 max-md:dark:border-neutral-700" |
| 23 | | @click="goRandom" |
| 24 | | title="I'm feeling lucky" |
| 25 | | > |
| 9 | <div class="mt-2 overflow-hidden rounded-lg border-2 border-solid border-$vp-c-default-soft relative z-0 max-md:border max-md:border-neutral-200 max-md:dark:border-neutral-700"> |
| 26 | 10 | <img |
| 27 | 11 | src="/soemy.webp" |
| 28 | 12 | alt="" |
| @@ -33,17 +17,7 @@ function goRandom() { |
| 33 | 17 | </template> |
| 34 | 18 | |
| 35 | 19 | <style scoped> |
| 36 | | div { |
| 37 | | cursor: pointer; |
| 38 | | } |
| 39 | | |
| 40 | | div:hover img { |
| 41 | | opacity: 0.85; |
| 42 | | transition: opacity 0.2s; |
| 43 | | } |
| 44 | | |
| 45 | 20 | img { |
| 46 | 21 | pointer-events: none; |
| 47 | | transition: opacity 0.2s; |
| 48 | 22 | } |
| 49 | 23 | </style> |
| \ No newline at end of file |