mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Core: Downgrade Orama to v2 to fix external tokenizers
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-core': patch
|
||||
---
|
||||
|
||||
Downgrade Orama to v2 to fix external tokenizers
|
||||
@@ -161,7 +161,7 @@ Orama requires extra configurations for Chinese, Japanese, and some other langua
|
||||
|
||||
```json doc-gen:file
|
||||
{
|
||||
"file": "../../examples/i18n/app/api/search/route-cn.ts",
|
||||
"file": "../../examples/i18n/app/api/search/route.ts",
|
||||
"codeblock": {
|
||||
"lang": "ts",
|
||||
"meta": "title=\"app/api/search/route.ts\""
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { createFromSource } from 'fumadocs-core/search/server';
|
||||
// @ts-expect-error -- untyped
|
||||
import { createTokenizer } from '@orama/tokenizers/mandarin';
|
||||
import { stopwords } from '@orama/stopwords/mandarin';
|
||||
|
||||
export const { GET, search } = createFromSource(source, undefined, {
|
||||
localeMap: {
|
||||
// the prop name should be its locale code in your i18n config, (e.g. `cn`)
|
||||
cn: {
|
||||
// options for the language
|
||||
tokenizer: await createTokenizer({
|
||||
stopWords: stopwords,
|
||||
}),
|
||||
search: {
|
||||
threshold: 0,
|
||||
tolerance: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,21 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { createFromSource } from 'fumadocs-core/search/server';
|
||||
// @ts-expect-error -- untyped
|
||||
import { createTokenizer } from '@orama/tokenizers/mandarin';
|
||||
import { stopwords } from '@orama/stopwords/mandarin';
|
||||
|
||||
export const { GET } = createFromSource(source);
|
||||
export const { GET, search } = createFromSource(source, undefined, {
|
||||
localeMap: {
|
||||
// the prop name should be its locale code in your i18n config, (e.g. `cn`)
|
||||
cn: {
|
||||
// options for the language
|
||||
tokenizer: await createTokenizer({
|
||||
stopWords: stopwords,
|
||||
}),
|
||||
search: {
|
||||
threshold: 0,
|
||||
tolerance: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@orama/stopwords": "^3.0.2",
|
||||
"@orama/tokenizers": "^3.0.2",
|
||||
"@orama/stopwords": "^2.1.1",
|
||||
"@orama/tokenizers": "^2.1.1",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@formatjs/intl-localematcher": "^0.5.8",
|
||||
"@orama/orama": "^3.0.2",
|
||||
"@orama/orama": "^2.1.1",
|
||||
"@shikijs/rehype": "^1.24.0",
|
||||
"github-slugger": "^2.0.0",
|
||||
"hast-util-to-estree": "^3.1.0",
|
||||
@@ -96,6 +96,7 @@
|
||||
"unist-util-visit": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.2",
|
||||
"@algolia/client-search": "4.24.0",
|
||||
"@mdx-js/mdx": "^3.1.0",
|
||||
"@oramacloud/client": "^2.1.4",
|
||||
@@ -118,7 +119,7 @@
|
||||
"unified": "^11.0.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@oramacloud/client": "1.x.x",
|
||||
"@oramacloud/client": "1.x.x || 2.x.x",
|
||||
"algoliasearch": "4.24.0",
|
||||
"next": "14.x.x || 15.x.x",
|
||||
"react": ">= 18",
|
||||
|
||||
@@ -58,19 +58,19 @@ export function createStaticClient({
|
||||
const data = (await res.json()) as ExportedData;
|
||||
|
||||
if (data.type === 'i18n') {
|
||||
Object.entries(data.data).forEach(([k, v]) => {
|
||||
const db = create({ schema: { _: 'string' } });
|
||||
for (const [k, v] of Object.entries(data.data)) {
|
||||
const db = await create({ schema: { _: 'string' } });
|
||||
|
||||
load(db, v);
|
||||
await load(db, v);
|
||||
dbs.set(k, {
|
||||
type: v.type,
|
||||
db,
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const db = create({ schema: { _: 'string' } });
|
||||
const db = await create({ schema: { _: 'string' } });
|
||||
|
||||
load(db, data);
|
||||
await load(db, data);
|
||||
dbs.set('', {
|
||||
type: data.type,
|
||||
db,
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function createDBSimple({
|
||||
language,
|
||||
}: SimpleOptions): Promise<Orama<typeof schema>> {
|
||||
const items = typeof indexes === 'function' ? await indexes() : indexes;
|
||||
const db = create({
|
||||
const db = await create({
|
||||
language,
|
||||
schema: {
|
||||
url: 'string',
|
||||
|
||||
@@ -25,7 +25,7 @@ export async function createDB({
|
||||
}: AdvancedOptions): Promise<Orama<typeof advancedSchema>> {
|
||||
const items = typeof indexes === 'function' ? await indexes() : indexes;
|
||||
|
||||
const db = create({
|
||||
const db = await create({
|
||||
...rest,
|
||||
schema: advancedSchema,
|
||||
components: {
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function searchAdvanced(
|
||||
for (const item of result.groups ?? []) {
|
||||
const pageId = item.values[0] as string;
|
||||
|
||||
const page = getByID(db, pageId);
|
||||
const page = await getByID(db, pageId);
|
||||
if (!page) continue;
|
||||
|
||||
list.push({
|
||||
|
||||
Generated
+22
-13
@@ -272,11 +272,11 @@ importers:
|
||||
examples/i18n:
|
||||
dependencies:
|
||||
'@orama/stopwords':
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
'@orama/tokenizers':
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
fumadocs-core:
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/core
|
||||
@@ -508,8 +508,8 @@ importers:
|
||||
specifier: ^0.5.8
|
||||
version: 0.5.8
|
||||
'@orama/orama':
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
'@shikijs/rehype':
|
||||
specifier: ^1.24.0
|
||||
version: 1.24.0
|
||||
@@ -610,6 +610,9 @@ importers:
|
||||
tsconfig:
|
||||
specifier: workspace:*
|
||||
version: link:../tsconfig
|
||||
typescript:
|
||||
specifier: ^5.7.2
|
||||
version: 5.7.2
|
||||
unified:
|
||||
specifier: ^11.0.5
|
||||
version: 11.0.5
|
||||
@@ -2120,16 +2123,20 @@ packages:
|
||||
'@orama/[email protected]':
|
||||
resolution: {integrity: sha512-Lcak3chblMejdlSHgYU2lS2cdOhDpU6vkfIJH4m+YKvqQyLqs1bB8+w6NT1MG5bO12NUK2GFc34Mn2xshMIQ1g==}
|
||||
|
||||
'@orama/[email protected]':
|
||||
resolution: {integrity: sha512-euTV/2kya290SNkl5m8e/H1na8iDygk74nNtl4E0YZNyYIrEMwE1JwamoroMKGZw2Uz+in/8gH3m1+2YfP0j1w==}
|
||||
engines: {node: '>= 16.0.0'}
|
||||
|
||||
'@orama/[email protected]':
|
||||
resolution: {integrity: sha512-1dfxup89K2DB2bbfx9rXyr/IAvhCKbH79lZCXVh5HWvdJ9g0VAvPIs3+UzjiyOdycEHYTbYundCTN6+Ygj3z4w==}
|
||||
engines: {node: '>= 16.0.0'}
|
||||
|
||||
'@orama/stopwords@3.0.2':
|
||||
resolution: {integrity: sha512-nGwv8TQjQdlxCbRsXB7A57vyh42jbQGw2xm2bYJD8vlFccJttFqeHqm9gHJji+tPPaQtys8gjkd+ly1c4KzLEg==}
|
||||
'@orama/stopwords@2.1.1':
|
||||
resolution: {integrity: sha512-zN/955DJBJgyE0OcB0YiuCxfrHpxNRTlZyTAQ8Quikn1EF8DaV9Tay8uzIR5qgF6GvpDJM9UD1O1SDB6zl/88Q==}
|
||||
engines: {node: '>= 16.0.0'}
|
||||
|
||||
'@orama/tokenizers@3.0.2':
|
||||
resolution: {integrity: sha512-pXfvaOdKbNUaMcEfirSfR9EGZa45t+eaEldmm3VelbkLo4TROlpEP9XTpbgAAkSSn5swKkuj+vrqBmOFcv7Q+A==}
|
||||
'@orama/tokenizers@2.1.1':
|
||||
resolution: {integrity: sha512-q/u1CO/BhqN3w+k+bcsas/ThxtsdAo7snEfRBVAVk3G6zvRT6sXix7ADmWdSVJ8gNSG9JWF+EANPzktL7U6zDg==}
|
||||
engines: {node: '>= 18.0.0'}
|
||||
|
||||
'@oramacloud/[email protected]':
|
||||
@@ -7358,13 +7365,15 @@ snapshots:
|
||||
dependencies:
|
||||
'@noble/hashes': 1.6.0
|
||||
|
||||
'@orama/[email protected]': {}
|
||||
|
||||
'@orama/[email protected]': {}
|
||||
|
||||
'@orama/stopwords@3.0.2': {}
|
||||
'@orama/stopwords@2.1.1': {}
|
||||
|
||||
'@orama/tokenizers@3.0.2':
|
||||
'@orama/tokenizers@2.1.1':
|
||||
dependencies:
|
||||
'@orama/orama': 3.0.2
|
||||
'@orama/orama': 2.1.1
|
||||
|
||||
'@oramacloud/[email protected]':
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user