Skip to content

Commit 1478715

Browse files
committed
Apply similar Maintenance LTS fallback to Orama logic
1 parent dd69c9c commit 1478715

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

apps/site/scripts/orama-search/get-documents.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ const fetchOptions = process.env.GITHUB_TOKEN
1818
export const getAPIDocs = async () => {
1919
// Find the current Active LTS version
2020
const releaseData = await generateReleaseData();
21-
const { versionWithPrefix } = releaseData.find(
22-
r => r.status === 'Active LTS'
23-
);
21+
const ltsRelease =
22+
releaseData.find(r => r.status === 'Active LTS') ||
23+
releaseData.find(r => r.status === 'Maintenance LTS');
24+
25+
if (!ltsRelease) {
26+
throw new Error('No Active LTS or Maintenance LTS release found');
27+
}
2428

2529
// Get list of API docs from the Node.js repo
2630
const fetchResponse = await fetch(
27-
`https://api.github.com/repos/nodejs/node/contents/doc/api?ref=${versionWithPrefix}`,
31+
`https://api.github.com/repos/nodejs/node/contents/doc/api?ref=${ltsRelease.versionWithPrefix}`,
2832
fetchOptions
2933
);
3034
const documents = await fetchResponse.json();
@@ -36,7 +40,7 @@ export const getAPIDocs = async () => {
3640

3741
return {
3842
content: await res.text(),
39-
pathname: `docs/${versionWithPrefix}/api/${basename(name, '.md')}.html`,
43+
pathname: `docs/${ltsRelease.versionWithPrefix}/api/${basename(name, '.md')}.html`,
4044
};
4145
})
4246
);

0 commit comments

Comments
 (0)