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.
vitepress/docs/guide/data-loading.md

50 lines
522 B

2 years ago
## Basic Usage
```js
export default {
load() {
return {
data: 'hello'
}
}
}
```
```js
export default {
async load() {
return (await fetch('...')).json()
}
}
```
## Generating Data Based On Local Files
```js
import { readDirSync } from 'node:fs'
export default {
watch: ['*.md'],
async load() {
//
}
}
```
## Typed Data
```ts
export interface Data {
// data type
}
declare const data: Data
export { data }
export default {
async load(): Promise<Data> {
// ...
}
}
```