Custom Search
For other search solutions.
Overview
You can integrate any search engine with Fumadocs.
Search Indexes
@fumadocs/astro exposes the search indexes of your pages at runtime.
To export them statically, add a pre-rendered static.json route, and process its records with a script after each build:
import type { APIRoute } from 'astro';
import { source } from '@/lib/source';
async function getDocuments() {
const documents = [];
for (const page of source.getPages()) {
documents.push({
structured: await page.data.structuredData(),
url: page.url,
title: page.data.title,
description: page.data.description,
});
}
return documents;
}
export const prerender = true;
export const GET: APIRoute = async () => Response.json(await getDocuments());
The structured field holds the headings and paragraphs of each page. Use it to generate accurate search indexes.
How is this guide?
Last updated on
