Skip to content

need help migrating Built-in Search to static #1328

Answered by fuma-nama
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

Did you turn on async intentionally? It is still an internal feature.

If yes, you need to load all the pages ahead of time:

import { source } from '@/lib/source';
import { createSearchAPI } from 'fumadocs-core/search/server';
 
export const { GET } = createSearchAPI('advanced', {
  indexes: await Promise.all(source.getPages().map(async (page) => ({
    title: page.data.title,
    description: page.data.description,
    url: page.url,
    id: page.url,
    structuredData: (await page.data.load()).structuredData,
  }))),
});

Otherwise removing async: true should be able to fix your problem.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant