From 5325174652b2320388a6fcdddfea9f8e0dd1a69c Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Tue, 16 Jun 2026 23:55:49 -0500 Subject: [PATCH 1/2] fix: improve path segment handling in orama-documents script --- .github/workflows/sync-orama.yml | 2 +- scripts/orama-documents.mjs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync-orama.yml b/.github/workflows/sync-orama.yml index 0402cac23d..b5575f8ec1 100644 --- a/.github/workflows/sync-orama.yml +++ b/.github/workflows/sync-orama.yml @@ -20,7 +20,7 @@ jobs: sync-orama-cloud: name: Sync Orama Cloud runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]' steps: - name: 'Checkout' diff --git a/scripts/orama-documents.mjs b/scripts/orama-documents.mjs index 0b9a9668b1..4274595e89 100644 --- a/scripts/orama-documents.mjs +++ b/scripts/orama-documents.mjs @@ -12,6 +12,13 @@ const stripMdxImports = (content) => content.replace(/^import\s+.*$/gm, ''); const mdToText = (content) => toString(fromMarkdown(stripMdxImports(content))).replace(/<[^>]*>/g, ''); +// Build the public path segment from a content-relative file path: drop the +// extension and any trailing `index` so `foo/index.mdx` -> `foo`. This matches +// Astro's glob loader, which serves index files at their directory URL (without +// a trailing `/index`). +const toPathSegment = (relPath) => + relPath.replace(/\.mdx?$/, '').replace(/(?:^|\/)index$/, ''); + const collectMdFiles = async (dir, base = dir) => { const entries = await readdir(dir); const results = await Promise.all( @@ -35,14 +42,14 @@ export const getPages = async (lang) => { const fullPath = join(baseDir, file); const raw = await readFile(fullPath, 'utf-8'); const { data, content } = matter(raw); - const pathSegment = relative(baseDir, fullPath).replace(/\.mdx?$/, ''); + const pathSegment = toPathSegment(relative(baseDir, fullPath)); const isResource = pathSegment.startsWith('resources'); return { title: data.title ?? basename(file).replace(/\.mdx?$/, ''), description: data.description ?? '', content: mdToText(content), - path: `/${lang}/${pathSegment}`, + path: `/${lang}/${pathSegment}`.replace(/\/+$/, ''), category: isResource ? 'menu.main.resources' : 'menu.main.docs', }; }) @@ -58,13 +65,13 @@ export const getDocs = async (lang) => { const fullPath = join(baseDir, file); const raw = await readFile(fullPath, 'utf-8'); const { data, content } = matter(raw); - const pathSegment = relative(baseDir, fullPath).replace(/\.mdx?$/, ''); + const pathSegment = toPathSegment(relative(baseDir, fullPath)); return { title: data.title ?? basename(file).replace(/\.mdx?$/, ''), description: data.description ?? '', content: mdToText(content), - path: `/${lang}/${pathSegment}`, + path: `/${lang}/${pathSegment}`.replace(/\/+$/, ''), category: 'menu.main.docs', }; }) @@ -106,13 +113,13 @@ export const getApi = async (lang) => { const fullPath = join(baseDir, file); const raw = await readFile(fullPath, 'utf-8'); const { data, content } = matter(raw); - const pathSegment = relative(baseDir, fullPath).replace(/\.mdx?$/, ''); + const pathSegment = toPathSegment(relative(baseDir, fullPath)); return { title: data.title ?? basename(file).replace(/\.mdx?$/, ''), description: data.description ?? '', content: mdToText(content), - path: `/${lang}/${version}/${pathSegment}`, + path: `/${lang}/${version}/${pathSegment}`.replace(/\/+$/, ''), category: 'menu.main.api', version, }; From 369bb93a89539ce0b4647169f9193814f7cdda2f Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Tue, 16 Jun 2026 23:59:41 -0500 Subject: [PATCH 2/2] fixup! --- scripts/orama-documents.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/orama-documents.mjs b/scripts/orama-documents.mjs index 4274595e89..414599f021 100644 --- a/scripts/orama-documents.mjs +++ b/scripts/orama-documents.mjs @@ -16,8 +16,7 @@ const mdToText = (content) => // extension and any trailing `index` so `foo/index.mdx` -> `foo`. This matches // Astro's glob loader, which serves index files at their directory URL (without // a trailing `/index`). -const toPathSegment = (relPath) => - relPath.replace(/\.mdx?$/, '').replace(/(?:^|\/)index$/, ''); +const toPathSegment = (relPath) => relPath.replace(/\.mdx?$/, '').replace(/(?:^|\/)index$/, ''); const collectMdFiles = async (dir, base = dir) => { const entries = await readdir(dir);