diff --git a/apify-docs-theme/src/theme/Layout/index.jsx b/apify-docs-theme/src/theme/Layout/index.jsx index 2ca67c8a9..389297ebc 100644 --- a/apify-docs-theme/src/theme/Layout/index.jsx +++ b/apify-docs-theme/src/theme/Layout/index.jsx @@ -3,10 +3,12 @@ import { useLocation } from '@docusaurus/router'; // cannot use any of the theme aliases here as it causes a circular dependency :( ideas welcome import Layout from '@docusaurus/theme-classic/lib/theme/Layout/index'; import useBaseUrl from '@docusaurus/useBaseUrl'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import { usePluginData } from '@docusaurus/useGlobalData'; import React from 'react'; export default function LayoutWrapper(props) { + const { siteConfig } = useDocusaurusContext(); const { options: { subNavbar } } = usePluginData('@apify/docs-theme'); const baseUrl = useBaseUrl('/'); const currentPath = useLocation().pathname.replace(new RegExp(`^${baseUrl}`), ''); @@ -14,7 +16,7 @@ export default function LayoutWrapper(props) { return ( <> - + {currentPath && }
} */ module.exports = { @@ -264,7 +264,8 @@ module.exports = { }), [ '@signalwire/docusaurus-plugin-llms-txt', - { + /** @type {import('@signalwire/docusaurus-plugin-llms-txt').PluginOptions} */ + ({ content: { includeVersionedDocs: false, enableLlmsFullTxt: true, @@ -272,6 +273,14 @@ module.exports = { includeGeneratedIndex: false, includePages: true, relativePaths: false, + remarkStringify: { + handlers: { + link: (node) => { + const isUrlInternal = isInternal(node.url); + return `[${node.title}](${isUrlInternal ? `${config.absoluteUrl}${node.url}` : node.url})`; + }, + }, + }, excludeRoutes: [ '/', ], @@ -294,7 +303,7 @@ module.exports = { }, ], }, - }, + }), ], // TODO this should be somehow computed from all the external sources // [ diff --git a/package-lock.json b/package-lock.json index 7b9221107..acadbe502 100644 --- a/package-lock.json +++ b/package-lock.json @@ -74,7 +74,7 @@ }, "apify-docs-theme": { "name": "@apify/docs-theme", - "version": "1.0.194", + "version": "1.0.197", "license": "ISC", "dependencies": { "@apify/docs-search-modal": "^1.2.2", 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 {