Core: Fix static export map

This commit is contained in:
Fuma Nama
2025-07-02 23:15:32 +08:00
parent 0ece7a76e1
commit 1a902fff23
3 changed files with 16 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---
Fix static export map
@@ -129,7 +129,7 @@ export function createI18nSearchAPI<T extends 'simple' | 'advanced'>(
return createEndpoint({
async export() {
const map = await get;
const entries = Object.entries(map).map(async ([k, v]) => [
const entries = Array.from(map.entries()).map(async ([k, v]) => [
k,
await (v as SearchServer).export(),
]);
+10
View File
@@ -97,4 +97,14 @@ test('Search API I18n', async () => {
expect(await api.search('English', { locale: 'en' })).toHaveLength(1);
expect(await api.search('amico', { locale: 'italian' })).toHaveLength(1);
expect(await api.search('italian', { locale: 'en' })).toHaveLength(0);
const exported = await api.export();
expect(exported.type).toBe('i18n');
if (exported.type === 'i18n')
expect(Object.keys(exported.data)).toMatchInlineSnapshot(`
[
"italian",
"en",
]
`);
});