mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
21 lines
515 B
TypeScript
21 lines
515 B
TypeScript
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 })
|
|
})
|
|
}
|
|
})
|