Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sync-orama.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
18 changes: 12 additions & 6 deletions scripts/orama-documents.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ 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(
Expand All @@ -35,14 +41,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',
};
})
Expand All @@ -58,13 +64,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',
};
})
Expand Down Expand Up @@ -106,13 +112,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,
};
Expand Down
Loading