Skip to content
Merged
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
12 changes: 12 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ const { collectSlugs } = require('./tools/utils/collectSlugs');
const { externalLinkProcessor, isInternal } = require('./tools/utils/externalLink');
const { removeLlmButtons } = require('./tools/utils/removeLlmButtons');

/**
* Helper to extract text from a node recursively.
*/
function getNodeText(node) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any utils file/folder so I've just placed it here but let me know if there is more appropriate place to put this function in.

if (node.type === 'text' || node.type === 'code' || node.type === 'inlineCode') return node.value || '';
if (node.children) return node.children.map(getNodeText).join('');
return '';
}

/** @type {Partial<import('@docusaurus/types').DocusaurusConfig>} */
module.exports = {
title: 'Apify Documentation',
Expand Down Expand Up @@ -301,7 +310,10 @@ module.exports = {
const url = isUrlInternal ? `${config.absoluteUrl}${parsedUrl.pathname}.md` : node.url;

if (isUrlInternal && !parsedUrl.pathname) return '';

if (node.title) return `[${node.title}](${url})`;
const linkText = getNodeText(node);
if (linkText) return `[${linkText}](${url})`;
return url;
},
code: (node) => {
Expand Down
Loading