Nitro
Serve content from a minimal Nitro server.
Setting up your own server? Follow the Nitro integration guide step by step.
content.ts
import { comarkContent, type JsonSchema } from 'comark-content'
import unstorage from 'comark-content/sources/unstorage'
import { z } from 'zod'
import { useStorage } from 'nitro/storage'
const Page = z.object({
title: z.string(),
description: z.string(),
})
export const content = comarkContent({
source: unstorage({
driver: useStorage('assets/pages'),
schema: z.toJSONSchema(Page) as JsonSchema,
}),
cache: import.meta.env.DEV
? false
: {
driver: useStorage('cache'),
},
})
export default { fetch: content.handler }