Create server/routes/algolia.json.ts
import { serverQueryContent } from '#content/server'export default defineEventHandler(async (event) => { // get content/tutorials const docs = await serverQueryContent(event, '/tutorials').find() // filter away _index file return docs.filter(doc => !doc._path.endsWith("/_index")).map(doc => { return { objectID: doc._id, date: doc.date, lastmod: doc.lastmod || doc.date, title: doc.title, description: doc.description, tags: doc.tags, path: doc._path } })})
You can generate the json file via http://localhost:3000/algolia.json
If you generate static website, edit nuxt.config.ts
export default defineNuxtConfig({ nitro: { prerender: { routes: ['/algolia.json'], } }})
dist/algolia.json
shall be generated after you run npm run generate
NOTE: If you prefer create index via Algolia API, try algolia/nuxt.