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

522 B

Basic Usage

export default {
  load() {
    return {
      data: 'hello'
    }
  }
}
export default {
  async load() {
    return (await fetch('...')).json()
  }
}

Generating Data Based On Local Files

import { readDirSync } from 'node:fs'

export default {
  watch: ['*.md'],
  async load() {
    //
  }
}

Typed Data

export interface Data {
  // data type
}

declare const data: Data
export { data }

export default {
  async load(): Promise<Data> {
    // ...
  }
}