Initial rearrangment of vuetom site source
This commit is contained in:
7
packages/blog/.vitepress/conf/path.ts
Normal file
7
packages/blog/.vitepress/conf/path.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import path from 'path'
|
||||
|
||||
export const vpRoot = path.resolve(__dirname, '..')
|
||||
export const blogRoot = path.resolve(vpRoot, '..')
|
||||
export const pageRoot = path.resolve(blogRoot, 'posts')
|
||||
export const pkgsRoot = path.resolve(blogRoot, '..')
|
||||
export const projRoot = path.resolve(pkgsRoot, '..')
|
26
packages/blog/.vitepress/conf/posts.ts
Normal file
26
packages/blog/.vitepress/conf/posts.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import fs from 'fs'
|
||||
import { pageRoot } from './path'
|
||||
|
||||
const readDir = (dir) => {
|
||||
const res = []
|
||||
const files = fs.readdirSync(dir)
|
||||
files.forEach(item => {
|
||||
const filepath = `${dir}/${item}`
|
||||
const stat = fs.statSync(filepath)
|
||||
if (stat.isFile()) {
|
||||
const name = item.replace('.md', '')
|
||||
res.push({
|
||||
text: name,
|
||||
link: `/${name}`
|
||||
})
|
||||
}
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
const getDefaultPage = () => ({
|
||||
text: '',
|
||||
link: ''
|
||||
})
|
||||
|
||||
export default () => readDir(pageRoot)
|
Reference in New Issue
Block a user