mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-08-17 23:19:55 +08:00
chore: 调整代码执行细节
This commit is contained in:
parent
f0451e0a72
commit
a89c4a8d31
@ -1,5 +1,5 @@
|
|||||||
import { defineConfig } from 'vitepress'
|
import { defineConfig } from 'vitepress'
|
||||||
import generateSideBar from './scripts/generateSideBar'
|
import { indexArticleSidebar } from './scripts/indexArticleSidebar'
|
||||||
import { projects, works, notes, JUEJIN } from './const'
|
import { projects, works, notes, JUEJIN } from './const'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@ -45,7 +45,7 @@ export default defineConfig({
|
|||||||
{
|
{
|
||||||
text: '文章归档',
|
text: '文章归档',
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [...generateSideBar()]
|
items: [...indexArticleSidebar()]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '学习笔记',
|
text: '学习笔记',
|
||||||
@ -66,7 +66,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
message: 'Released under the MIT License.',
|
message: 'Released under the MIT License.',
|
||||||
copyright: 'Copyright © 2019-present Ziu Chen'
|
copyright: 'Copyright © 2022-PRESENT ZiuChen'
|
||||||
},
|
},
|
||||||
lastUpdatedText: 'Updated Date',
|
lastUpdatedText: 'Updated Date',
|
||||||
search: {
|
search: {
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
import fs from 'fs'
|
|
||||||
import path from 'path'
|
|
||||||
|
|
||||||
export default function generateSideBar() {
|
|
||||||
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
|
||||||
|
|
||||||
const sidebar = articles
|
|
||||||
.filter((article) => article.endsWith('.md'))
|
|
||||||
.map((article) => {
|
|
||||||
// 移除后缀 `.md`
|
|
||||||
const title = article.replace(/\.md$/, '')
|
|
||||||
return {
|
|
||||||
text: title,
|
|
||||||
link: `/article/${title}`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return sidebar
|
|
||||||
}
|
|
16
docs/.vitepress/scripts/indexArticleSidebar.ts
Normal file
16
docs/.vitepress/scripts/indexArticleSidebar.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成文章侧边栏
|
||||||
|
*/
|
||||||
|
export function indexArticleSidebar() {
|
||||||
|
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
||||||
|
|
||||||
|
return articles
|
||||||
|
.filter((article) => article.endsWith('.md'))
|
||||||
|
.map((article) => ({
|
||||||
|
text: article.replace(/\.md$/, ''),
|
||||||
|
link: `/article/${article}`
|
||||||
|
}))
|
||||||
|
}
|
@ -9,6 +9,6 @@ export function customComponents(app: App) {
|
|||||||
const cpns = [Title, ImgSlider]
|
const cpns = [Title, ImgSlider]
|
||||||
|
|
||||||
for (const c of cpns) {
|
for (const c of cpns) {
|
||||||
app.component(c.__name, c)
|
app.component(c.__name!, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ let lastHashmap: any = null
|
|||||||
* 如果有更新则弹出提醒刷新页面
|
* 如果有更新则弹出提醒刷新页面
|
||||||
*/
|
*/
|
||||||
export function refresh() {
|
export function refresh() {
|
||||||
// SSR or SSG 模式不需要检查更新
|
// SSR or DEV 下不需要检查更新
|
||||||
if (import.meta.env.SSR) {
|
if (import.meta.env.SSR || import.meta.env.DEV) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user