Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit b0e8b45

Browse files
committed
chore: revert verison and debugging slots
1 parent 62cf25f commit b0e8b45

File tree

10 files changed

+2645
-9673
lines changed

10 files changed

+2645
-9673
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"@cypress/snapshot": "^2.1.7",
5353
"@cypress/vite-dev-server": "^1.2.6",
5454
"@cypress/vue": "^3.0.1",
55+
"@docusaurus/utils": "^2.0.0-beta.3",
5556
"@emotion/css": "^11.1.3",
5657
"@emotion/server": "^11.0.0",
5758
"@manypkg/cli": "^0.17.0",
@@ -67,7 +68,9 @@
6768
"@types/lodash.kebabcase": "^4.1.6",
6869
"@types/lodash.mergewith": "^4.6.6",
6970
"@types/recursive-readdir": "^2.2.0",
71+
"@types/shelljs": "^0.8.9",
7072
"@types/tinycolor2": "^1.4.2",
73+
"@types/uuid": "^8.3.1",
7174
"@typescript-eslint/eslint-plugin": "^2.34.0",
7275
"@typescript-eslint/parser": "4.0.1",
7376
"@vitejs/plugin-vue": "^1.2.1",
@@ -130,13 +133,14 @@
130133
"pretty": "^2.0.0",
131134
"react": "^17.0.1",
132135
"recursive-readdir": "^2.2.2",
136+
"shelljs": "^0.8.4",
133137
"tinycolor2": "^1.4.2",
134138
"ts-jest": "^26.5.0",
135139
"ts-node": "^9.0.0",
136140
"typescript": "^4.1.3",
137141
"vite": "^2.4.0",
138142
"vite-plugin-components": "^0.8.3",
139-
"vite-plugin-mdx-vue": "^1.6.0",
143+
"vite-plugin-mdx-vue": "^1.1.3",
140144
"vite-plugin-pages": "^0.9.2",
141145
"vite-ssg": "^0.11.4",
142146
"vitepress": "^0.12.0",

scripts/generate-search-meta.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { parseMarkdownFile, fileToPath, removePrefix } from '@docusaurus/utils'
2+
import path from 'path'
3+
//@ts-ignore
4+
import toc from 'markdown-toc'
5+
import { v4 as uuid } from 'uuid'
6+
import shell from 'shelljs'
7+
import fs from 'graceful-fs'
8+
import prettier from 'prettier'
9+
10+
interface ResultType {
11+
content: string
12+
id: string
13+
url: string
14+
type: 'lvl1' | 'lvl2' | 'lvl3'
15+
hierarchy: {
16+
lvl1: string | null
17+
lvl2?: string | null
18+
lvl3?: string | null
19+
}
20+
}
21+
22+
interface TOCResultItem {
23+
content: string
24+
slug: string
25+
lvl: 1 | 2 | 3
26+
i: number
27+
seen: number
28+
}
29+
30+
const websiteRoot = 'website/src/pages'
31+
32+
async function getMDXMeta(file: string) {
33+
const { content, frontMatter } = await parseMarkdownFile(file)
34+
const tableOfContent = toc(content)
35+
const json = tableOfContent.json as TOCResultItem[]
36+
const slug = fileToPath(file)
37+
.replace(`/${websiteRoot}`, '')
38+
.replace(process.cwd(), '')
39+
40+
const result: ResultType[] = []
41+
42+
result.push({
43+
content: frontMatter.title as string,
44+
id: uuid(),
45+
type: 'lvl1',
46+
url: removePrefix(slug, '/'),
47+
hierarchy: {
48+
lvl1: frontMatter.title as string,
49+
},
50+
})
51+
52+
json.forEach((item, index) => {
53+
result.push({
54+
content: item.content,
55+
id: uuid(),
56+
type: `lvl${item.lvl}` as any,
57+
url: `${removePrefix(slug, '/')}#${item.slug}`,
58+
hierarchy: {
59+
lvl1: frontMatter.title as string,
60+
lvl2: item.lvl === 2 ? item.content : json[index - 1]?.content ?? null,
61+
lvl3: item.lvl === 3 ? item.content : null,
62+
},
63+
})
64+
})
65+
66+
return result
67+
}
68+
69+
async function getSearchMeta() {
70+
let json: any = []
71+
72+
const files = shell
73+
.ls('-R', websiteRoot)
74+
.map((file) => path.join(process.cwd(), websiteRoot, file))
75+
.filter((file) => file.endsWith('.mdx'))
76+
77+
files.forEach(async (file) => {
78+
let result: any[] = []
79+
try {
80+
result = await getMDXMeta(file)
81+
json.push(...result)
82+
} catch (error) {
83+
/** do nothing */
84+
}
85+
})
86+
87+
json = prettier.format(JSON.stringify(json), { parser: 'json' })
88+
const outPath = path.join(
89+
process.cwd(),
90+
'website/src/config',
91+
'search-meta.json'
92+
)
93+
fs.writeFileSync(outPath, json)
94+
console.log('Search meta is ready ✅')
95+
}
96+
97+
getSearchMeta()

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"vite-plugin-components": "^0.8.3",
4343
"vite-plugin-icons": "^0.3.3",
4444
"vite-plugin-md": "^0.6.0",
45-
"vite-plugin-mdx-vue": "^1.6.0",
45+
"vite-plugin-mdx-vue": "^1.1.3",
4646
"vite-plugin-pages": "^0.9.2",
4747
"vite-ssg": "^0.11.4"
4848
}

website/src/App.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<template>
22
<c-reset />
3-
<router-view v-slot="{ Component, route }">
3+
<!-- <router-view v-slot="{ Component, route }">
44
<c-container px="0" :max-w="route.path === '/' ? 'auto' : '1440px'">
5-
<!-- <c-animate-presence type="scale"> -->
5+
<c-animate-presence type="scale">
66
<component :is="Component" />
7-
<!-- </c-animate-presence> -->
7+
</c-animate-presence>
88
</c-container>
9-
</router-view>
9+
</router-view> -->
10+
<router-view />
1011
</template>
1112

1213
<script setup lang="ts">

website/src/config/guides-sidebar.json

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,12 @@
3030
"open": true,
3131
"routes": [
3232
{
33-
"title": "Create React App",
34-
"path": "/guides/integrations/with-cra"
33+
"title": "Vite",
34+
"path": "/guides/integrations/with-vite"
3535
},
3636
{
37-
"title": "Framer Motion",
38-
"path": "/guides/integrations/with-framer"
39-
},
40-
{
41-
"title": "React Hook Form",
42-
"path": "/guides/integrations/with-hook-form"
43-
},
44-
{
45-
"title": "React Table",
46-
"path": "/guides/integrations/with-react-table"
37+
"title": "Vue CLI",
38+
"path": "/guides/integrations/with-vue-cli"
4739
}
4840
]
4941
}

0 commit comments

Comments
 (0)