Skip to content

Commit

Permalink
Core: Upgrade to Orama v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Mar 1, 2025
1 parent 31abf6d commit 796cc5e
Show file tree
Hide file tree
Showing 26 changed files with 479 additions and 467 deletions.
5 changes: 5 additions & 0 deletions .changeset/fine-bags-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---

Upgrade to Orama v3
8 changes: 1 addition & 7 deletions apps/docs/app/docs/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default async function Page(props: {
params: Promise<{ slug: string[] }>;
}): Promise<ReactElement> {
const params = await props.params;
console.log('render', params.slug);
const page = source.getPage(params.slug);

if (!page) notFound();
Expand Down Expand Up @@ -135,10 +134,5 @@ export async function generateMetadata(props: {
}

export function generateStaticParams() {
console.log(
source
.generateParams()
.filter((v) => v.slug[0] === 'ui' && v.slug[1] === 'mdx'),
);
return [...source.generateParams()];
return source.generateParams();
}
6 changes: 3 additions & 3 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"geist": "^1.3.1",
"hast-util-to-jsx-runtime": "^2.3.5",
"katex": "^0.16.21",
"lucide-react": "^0.476.0",
"lucide-react": "^0.477.0",
"next": "15.2.0",
"octokit": "^4.1.2",
"oxc-transform": "^0.53.0",
Expand All @@ -60,7 +60,7 @@
"@tailwindcss/postcss": "^4.0.9",
"@types/hast": "^3.0.4",
"@types/mdx": "^2.0.13",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"eslint-config-custom": "workspace:*",
Expand All @@ -73,6 +73,6 @@
"ts-morph": "^25.0.1",
"tsconfig": "workspace:*",
"tsx": "^4.19.3",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
4 changes: 2 additions & 2 deletions examples/content-collections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"devDependencies": {
"@content-collections/core": "^0.8.0",
"@content-collections/mdx": "^0.2.0",
"@content-collections/next": "^0.2.4",
"@content-collections/next": "^0.2.5",
"@types/mdx": "^2.0.13",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
8 changes: 4 additions & 4 deletions examples/i18n/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { source } from '@/lib/source';
import { createFromSource } from 'fumadocs-core/search/server';
// @ts-expect-error -- untyped
import { createTokenizer } from '@orama/tokenizers/mandarin';

export const { GET } = createFromSource(source, undefined, {
localeMap: {
// you can customise search configs for specific locales, like:
// [locale]: settings
// [locale]: Orama options

// specify the tokenizer
cn: {
tokenizer: await createTokenizer(),
components: {
tokenizer: createTokenizer(),
},
search: {
threshold: 0,
tolerance: 0,
Expand Down
6 changes: 3 additions & 3 deletions examples/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@orama/stopwords": "^2.1.1",
"@orama/tokenizers": "^2.1.1",
"@orama/stopwords": "^3.1.1",
"@orama/tokenizers": "^3.1.1",
"fumadocs-core": "workspace:*",
"fumadocs-mdx": "workspace:*",
"fumadocs-ui": "workspace:*",
Expand All @@ -21,6 +21,6 @@
"@types/mdx": "^2.0.13",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
2 changes: 1 addition & 1 deletion examples/next-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"algoliasearch": "4.24.0",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
4 changes: 2 additions & 2 deletions examples/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types:check": "fumadocs-mdx && tsc --noEmit"
},
"dependencies": {
"@scalar/api-client-react": "^1.1.31",
"@scalar/api-client-react": "^1.1.33",
"fumadocs-core": "workspace:*",
"fumadocs-mdx": "workspace:*",
"fumadocs-openapi": "workspace:*",
Expand All @@ -29,6 +29,6 @@
"postcss": "^8.5.3",
"rimraf": "^6.0.1",
"tailwindcss": "^4.0.9",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
2 changes: 1 addition & 1 deletion examples/remote-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@types/mdx": "^2.0.13",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"rimraf": "^6.0.1",
"tsup": "8.4.0",
"turbo": "2.4.4",
"typescript": "^5.7.3",
"typescript-eslint": "^8.24.1",
"typescript": "^5.8.2",
"typescript-eslint": "^8.25.0",
"vitest": "^3.0.7"
},
"packageManager": "[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
"@clack/prompts": "^0.10.0",
"commander": "^13.1.0",
"execa": "^9.5.2",
"package-manager-detector": "^0.2.9",
"package-manager-detector": "^0.2.10",
"picocolors": "^1.1.1",
"ts-morph": "^25.0.1"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "^19.0.10",
"eslint-config-custom": "workspace:*",
"fast-glob": "^3.3.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/content-collections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"devDependencies": {
"@content-collections/core": "^0.8.0",
"@content-collections/mdx": "^0.2.0",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"eslint-config-custom": "workspace:*",
"fumadocs-core": "workspace:*",
"tsconfig": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
},
"dependencies": {
"@formatjs/intl-localematcher": "^0.6.0",
"@orama/orama": "^2.1.1",
"@orama/orama": "^3.1.1",
"@shikijs/rehype": "^3.1.0",
"@shikijs/transformers": "^3.1.0",
"github-slugger": "^2.0.0",
Expand All @@ -115,13 +115,13 @@
"devDependencies": {
"@algolia/client-search": "4.24.0",
"@mdx-js/mdx": "^3.1.0",
"@orama/tokenizers": "^2.1.1",
"@orama/tokenizers": "^3.1.1",
"@oramacloud/client": "^2.1.4",
"@types/estree-jsx": "^1.0.5",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/negotiator": "^0.6.3",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"algoliasearch": "4.24.0",
Expand All @@ -132,7 +132,7 @@
"remark-mdx": "^3.1.0",
"remark-rehype": "^11.1.1",
"tsconfig": "workspace:*",
"typescript": "^5.7.3",
"typescript": "^5.8.2",
"unified": "^11.0.5",
"vfile": "^6.0.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/search/orama/_stemmers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Cloned from Orama codebase */

/* Cloned from https://github.com/oramasearch/orama/blob/main/packages/orama/src/components/tokenizer/languages.ts */
export const STEMMERS: Record<string, string> = {
arabic: 'ar',
armenian: 'am',
bulgarian: 'bg',
czech: 'cz',
danish: 'dk',
dutch: 'nl',
english: 'en',
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/search/orama/create-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export async function createDB({
}: AdvancedOptions): Promise<Orama<typeof advancedSchema>> {
const items = typeof indexes === 'function' ? await indexes() : indexes;

const db = (await create({
const db = create({
schema: advancedSchema,
...rest,
components: {
...rest.components,
tokenizer: tokenizer ?? rest.components?.tokenizer,
},
})) as unknown as Orama<typeof advancedSchema>;
}) as Orama<typeof advancedSchema>;

const mapTo: PartialSchemaDeep<AdvancedDocument>[] = [];
items.forEach((page) => {
Expand Down Expand Up @@ -102,14 +102,14 @@ export async function createDBSimple({
...rest
}: SimpleOptions): Promise<Orama<typeof simpleSchema>> {
const items = typeof indexes === 'function' ? await indexes() : indexes;
const db = (await create({
const db = create({
schema: simpleSchema,
...rest,
components: {
...rest.components,
tokenizer: tokenizer ?? rest.components?.tokenizer,
},
})) as unknown as Orama<typeof simpleSchema>;
}) as Orama<typeof simpleSchema>;

await insertMultiple(
db,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/search/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function initSimpleSearch(options: SimpleOptions): SearchServer {
async export() {
return {
type: 'simple',
...(await save(await doc)),
...save(await doc),
};
},
async search(query) {
Expand Down Expand Up @@ -146,7 +146,7 @@ export function initAdvancedSearch(options: AdvancedOptions): SearchServer {
async export() {
return {
type: 'advanced',
...(await save(await get)),
...save(await get),
};
},
async search(query, searchOptions) {
Expand Down
6 changes: 3 additions & 3 deletions packages/create-app-versions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"dependencies": {
"@content-collections/core": "^0.8.0",
"@content-collections/mdx": "^0.2.0",
"@content-collections/next": "^0.2.4",
"@content-collections/next": "^0.2.5",
"@tailwindcss/postcss": "^4.0.9",
"@types/mdx": "^2.0.13",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"next": "15.2.0",
"postcss": "^8.5.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwindcss": "^4.0.9",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"eslint-config-custom": "workspace:*",
"fast-glob": "^3.3.3",
"tsconfig": "workspace:*"
Expand Down
6 changes: 3 additions & 3 deletions packages/doc-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"@types/estree": "^1.0.6",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"eslint-config-custom": "workspace:*",
"mdast-util-mdx-jsx": "^3.2.0",
"remark": "^15.0.0",
"tsconfig": "workspace:*",
"mdast-util-mdx-jsx": "^3.2.0",
"typescript": "^5.7.3",
"typescript": "^5.8.2",
"unified": "^11.0.5",
"vfile": "^6.0.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mdx-remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"devDependencies": {
"@types/mdx": "^2.0.13",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "^19.0.10",
"eslint-config-custom": "workspace:*",
"fast-glob": "^3.3.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@radix-ui/react-dialog": "^1.1.6",
"@radix-ui/react-select": "^2.1.6",
"@radix-ui/react-slot": "^1.1.2",
"@scalar/openapi-parser": "0.10.8",
"@scalar/openapi-parser": "0.10.9",
"ajv-draft-04": "^1.0.0",
"class-variance-authority": "^0.7.1",
"fast-glob": "^3.3.3",
Expand All @@ -63,7 +63,7 @@
"github-slugger": "^2.0.0",
"hast-util-to-jsx-runtime": "^2.3.5",
"js-yaml": "^4.1.0",
"lucide-react": "^0.476.0",
"lucide-react": "^0.477.0",
"next-themes": "^0.4.4",
"openapi-sampler": "^1.6.1",
"react-hook-form": "^7.54.2",
Expand All @@ -73,9 +73,9 @@
"xml-js": "^1.6.11"
},
"devDependencies": {
"@scalar/api-client-react": "^1.1.31",
"@scalar/api-client-react": "^1.1.33",
"@types/js-yaml": "^4.0.9",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/openapi-sampler": "^1.0.3",
"@types/react": "^19.0.10",
"eslint-config-custom": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/twoslash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"devDependencies": {
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "^19.0.10",
"eslint-config-custom": "workspace:*",
"fumadocs-ui": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
"@types/estree": "^1.0.6",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/node": "22.13.5",
"@types/node": "22.13.8",
"@types/react": "19.0.10",
"@types/react-dom": "19.0.4",
"eslint-config-custom": "workspace:*",
"fumadocs-core": "workspace:*",
"fumadocs-ui": "workspace:*",
"tsconfig": "workspace:*",
"typescript": "^5.7.3",
"typescript": "^5.8.2",
"unified": "^11.0.5"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@radix-ui/react-tabs": "^1.1.3",
"class-variance-authority": "^0.7.1",
"lodash.merge": "^4.6.2",
"lucide-react": "^0.476.0",
"lucide-react": "^0.477.0",
"next-themes": "^0.4.4",
"postcss-selector-parser": "^7.1.0",
"react-medium-image-zoom": "^5.2.14",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/layouts/docs/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ export function SidebarPageTree(props: {
return (
<Fragment key={root.$id}>{renderSidebarList(root.children, 1)}</Fragment>
);
// eslint-disable-next-line react-hooks/exhaustive-deps -- root.id is enough
}, [props.components, root.$id]);
}

Expand Down
Loading

0 comments on commit 796cc5e

Please sign in to comment.