Skip to content

Commit 05eb493

Browse files
Copilotbarjin
andauthored
fix: skip rel=alternate markdown link on versioned docs pages (#2283)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: barjin <61918049+barjin@users.noreply.github.com>
1 parent 9b625d7 commit 05eb493

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Head from '@docusaurus/Head';
2+
import { useAllDocsData } from '@docusaurus/plugin-content-docs/client';
23
import { useLocation } from '@docusaurus/router';
34
// cannot use any of the theme aliases here as it causes a circular dependency :( ideas welcome
45
import Layout from '@docusaurus/theme-classic/lib/theme/Layout/index';
@@ -9,8 +10,14 @@ import React from 'react';
910
export default function LayoutWrapper(props) {
1011
const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
1112
const baseUrl = useBaseUrl('/');
12-
const currentPath = useLocation().pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
13-
const shouldRenderAlternateLink = currentPath && currentPath !== '404';
13+
const { pathname } = useLocation();
14+
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)),
18+
);
19+
20+
const shouldRenderAlternateLink = currentPath && currentPath !== '404' && !isVersionedPage;
1421

1522
const alternateMarkdownLink = useBaseUrl(`/${currentPath}.md`, { absolute: true });
1623

0 commit comments

Comments
 (0)