mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
492 B
21 lines
492 B
2 years ago
|
import fs from 'fs'
|
||
2 years ago
|
import { defineLoader } from 'vitepress'
|
||
2 years ago
|
|
||
2 years ago
|
type Data = Record<string, boolean>[]
|
||
|
export declare const data: Data
|
||
|
|
||
2 years ago
|
export default defineLoader({
|
||
2 years ago
|
watch: ['./data/*'],
|
||
2 years ago
|
async load(files: string[]): Promise<Data> {
|
||
2 years ago
|
const foo = fs.readFileSync(
|
||
2 years ago
|
files.find((f) => f.endsWith('foo.json'))!,
|
||
2 years ago
|
'utf-8'
|
||
|
)
|
||
|
const bar = fs.readFileSync(
|
||
2 years ago
|
files.find((f) => f.endsWith('bar.json'))!,
|
||
2 years ago
|
'utf-8'
|
||
|
)
|
||
|
return [JSON.parse(foo), JSON.parse(bar)]
|
||
|
}
|
||
2 years ago
|
})
|