Nuxt/docs/modules/content/index.ts

21 lines
515 B
TypeScript
Raw Normal View History

2021-04-20 12:16:09 +00:00
import { resolve } from 'path'
import { defineNuxtModule, resolveModule, addServerMiddleware } from '@nuxt/kit'
export default defineNuxtModule({
name: 'content',
setup (_, nuxt) {
const runtimeDir = resolve(__dirname, 'runtime')
nuxt.hook('nitro:context', (ctx) => {
ctx.assets.dirs.content = {
dir: resolve(nuxt.options.rootDir, 'content')
}
})
addServerMiddleware({
path: '/api/content',
handler: resolveModule('./api', { paths: runtimeDir })
})
}
})