Skip to content

Commit 2b39751

Browse files
authored
fix: do not render <link rel=alternate on versioned API reference pages (#2292)
Checks the `docusaurus-plugin-typedoc-api` global data for available versions and only adds the markdown alternate link to "current" latest versions. Check e.g. `lychee` check for 404 links on the `/next` pages in `apify-client-js` ([link](https://github.com/apify/apify-client-js/actions/runs/22395917589#summary-64829405227)) <img width="1326" height="818" alt="image" src="https://github.com/user-attachments/assets/29b79be0-7393-4fc6-925e-20929cfb8549" />
1 parent c49d6b8 commit 2b39751

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

apify-docs-theme/src/theme/Layout/index.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ export default function LayoutWrapper(props) {
1212
const baseUrl = useBaseUrl('/');
1313
const { pathname } = useLocation();
1414
const currentPath = pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
15-
const allDocsData = useAllDocsData();
16-
const isVersionedPage = Object.values(allDocsData).some(
17-
(pluginData) => pluginData.versions.some((version) => !version.isLast && pathname.startsWith(version.path)),
15+
const docsPluginData = useAllDocsData();
16+
const typedocPluginData = usePluginData('docusaurus-plugin-typedoc-api') ?? {};
17+
18+
const allPluginData = {
19+
...docsPluginData,
20+
'typedoc-plugin-default': typedocPluginData,
21+
};
22+
23+
const isVersionedPage = Object.values(allPluginData).some(
24+
(pluginData) => pluginData.versions?.some((version) => !version.isLast && pathname.startsWith(version.path)),
1825
);
1926

2027
const shouldRenderAlternateLink = currentPath && currentPath !== '404' && !isVersionedPage;

0 commit comments

Comments
 (0)