Skip to content

Commit 935de60

Browse files
committed
fix: Pick the base url from env
1 parent b1db58a commit 935de60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/indentLlmsFile.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ const INDENTED_PATHS = ['/api/v2/', '/academy/', '/platform/', '/legal/'];
1212
// Main API pages that should have no indentation
1313
const MAIN_API_PAGES = ['/api.md', '/api/v2.md'];
1414

15+
const BASE_URL = process.env.APIFY_DOCS_ABSOLUTE_URL || 'https://docs.apify.com';
16+
console.log('debug: BASE_URL', BASE_URL);
1517
/**
1618
* Calculates the depth of a URL by counting non-file path segments.
1719
*/
1820
function getUrlDepth(url) {
19-
const baseUrl = url.replace('https://docs.apify.com', '');
21+
const baseUrl = url.replace(BASE_URL, '');
2022
const urlSegments = baseUrl.split('/').filter((segment) => segment && segment !== '');
2123
const nonFileSegments = urlSegments.filter((segment) => !segment.endsWith('.md'));
2224
return nonFileSegments.length;
@@ -55,8 +57,8 @@ function getIndentationLevel(line, lineIndex, allLines) {
5557
return INDENT_LEVEL * 2; // Sub-subsection title - 2 level indent
5658
}
5759

58-
if (line.startsWith('- [') && line.includes('](https://docs.apify.com/')) {
59-
const urlMatch = line.match(/\]\((https:\/\/docs\.apify\.com\/[^)]+)\)/);
60+
if (line.startsWith('- [') && line.includes(`](${BASE_URL}/`)) {
61+
const urlMatch = line.match(new RegExp(`\\]\\((${BASE_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/[^)]+)\\)`));
6062
if (!urlMatch) {
6163
return INDENT_LEVEL; // Fallback if URL parsing fails
6264
}

0 commit comments

Comments
 (0)