Skip to content

Commit 7afb909

Browse files
committed
fix: Fix markdown url links formatting
1 parent 9684a4f commit 7afb909

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docusaurus.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ const { collectSlugs } = require('./tools/utils/collectSlugs');
99
const { externalLinkProcessor, isInternal } = require('./tools/utils/externalLink');
1010
const { removeLlmButtons } = require('./tools/utils/removeLlmButtons');
1111

12+
/**
13+
* Helper to extract text from a node recursively.
14+
*/
15+
function getNodeText(node) {
16+
if (node.type === 'text' || node.type === 'code' || node.type === 'inlineCode') return node.value || '';
17+
if (node.children) return node.children.map(getNodeText).join('');
18+
return '';
19+
}
20+
1221
/** @type {Partial<import('@docusaurus/types').DocusaurusConfig>} */
1322
module.exports = {
1423
title: 'Apify Documentation',
@@ -301,7 +310,10 @@ module.exports = {
301310
const url = isUrlInternal ? `${config.absoluteUrl}${parsedUrl.pathname}.md` : node.url;
302311

303312
if (isUrlInternal && !parsedUrl.pathname) return '';
313+
304314
if (node.title) return `[${node.title}](${url})`;
315+
const linkText = getNodeText(node);
316+
if (linkText) return `[${linkText}](${url})`;
305317
return url;
306318
},
307319
code: (node) => {

0 commit comments

Comments
 (0)