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 {
1010 PagePropertiesMarkdownSection
1111} from '@nolebase/vitepress-plugin-page-properties/vite'
1212import { fileURLToPath, URL } from 'node:url'
13import { collectHeadingsPlugin } from '../plugins/collectHeadings'
1413import UnoCSS from 'unocss/vite'
1514import Devtools from 'vite-plugin-vue-devtools'
1615import type { DefaultTheme, Plugin, UserConfig } from 'vitepress'
@@ -108,7 +107,6 @@ export const shared: UserConfig<DefaultTheme.Config> = {
108107 ]
109108 },
110109 plugins: [
111 collectHeadingsPlugin(fileURLToPath(new URL('../../', import.meta.url))),
112110 Devtools(),
113111 PageProperties(),
114112 PagePropertiesMarkdownSection(),
@@ -150,4 +148,4 @@ export const shared: UserConfig<DefaultTheme.Config> = {
150148 ]
151149 }
152150 }
153}
\ No newline at end of file
151}
docs/.vitepress/plugins/collectHeadings.js deleted −48
@@ -1,48 +0,0 @@
1import { readdirSync, readFileSync, writeFileSync } from 'fs'
2import { join } from 'path'
3
4export 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
18function 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 @@
55
66 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.
77-->
8<script setup>
9import { useRouter } from 'vitepress'
10import headings from '../headings.json'
11
12const router = useRouter()
13
14function goRandom() {
15 const pick = headings[Math.floor(Math.random() * headings.length)]
16 router.go(pick.path + pick.anchor)
17}
18</script>
19
208<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">
2610 <img
2711 src="/soemy.webp"
2812 alt=""
@@ -33,17 +17,7 @@ function goRandom() {
3317</template>
3418
3519<style scoped>
36div {
37 cursor: pointer;
38}
39
40div:hover img {
41 opacity: 0.85;
42 transition: opacity 0.2s;
43}
44
4520img {
4621 pointer-events: none;
47 transition: opacity 0.2s;
4822}
4923</style>
\ No newline at end of file