diff --git a/docusaurus.config.js b/docusaurus.config.js index b27c7bd40..ce58992e5 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -5,7 +5,7 @@ const { createApiPageMD, createInfoPageMD } = require('docusaurus-plugin-openapi const { config } = require('./apify-docs-theme'); const { collectSlugs } = require('./tools/utils/collectSlugs'); -const { externalLinkProcessor } = require('./tools/utils/externalLink'); +const { externalLinkProcessor, isInternal } = require('./tools/utils/externalLink'); const { removeLlmButtons } = require('./tools/utils/removeLlmButtons'); /** @type {Partial} */ @@ -287,7 +287,8 @@ module.exports = { }), [ '@signalwire/docusaurus-plugin-llms-txt', - { + /** @type {import('@signalwire/docusaurus-plugin-llms-txt').PluginOptions} */ + ({ content: { includeVersionedDocs: false, enableLlmsFullTxt: true, @@ -295,6 +296,17 @@ module.exports = { includeGeneratedIndex: false, includePages: true, relativePaths: false, + remarkStringify: { + handlers: { + link: (node) => { + const isUrlInternal = isInternal(node.url); + const url = isUrlInternal ? `${config.absoluteUrl}${node.url}` : node.url; + + if (node.title) return `[${node.title}](${url})`; + return url; + }, + }, + }, excludeRoutes: [ '/', ], @@ -319,7 +331,7 @@ module.exports = { // Add custom remark processing to remove LLM button text remarkPlugins: [removeLlmButtons], }, - }, + }), ], // TODO this should be somehow computed from all the external sources // [ diff --git a/tools/utils/externalLink.js b/tools/utils/externalLink.js index b94fc8aff..774c4bf03 100644 --- a/tools/utils/externalLink.js +++ b/tools/utils/externalLink.js @@ -7,12 +7,12 @@ const internalUrls = ['sdk.apify.com']; /** * @param {import('url').UrlWithStringQuery} href */ -function isInternal(href) { +exports.isInternal = (href) => { return internalUrls.some( (internalUrl) => href.host === internalUrl || (!href.protocol && !href.host && (href.pathname || href.hash)), ); -} +}; /** * @type {import('unified').Plugin} @@ -27,7 +27,7 @@ exports.externalLinkProcessor = () => { ) { const href = parse(node.properties.href); - if (!isInternal(href)) { + if (!exports.isInternal(href)) { node.properties.target = '_blank'; node.properties.rel = 'noopener'; } else {