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
11 changes: 9 additions & 2 deletions apify-docs-theme/src/theme/Layout/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Head from '@docusaurus/Head';
import { useAllDocsData } from '@docusaurus/plugin-content-docs/client';
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';
Expand All @@ -9,8 +10,14 @@ import React from 'react';
export default function LayoutWrapper(props) {
const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
const baseUrl = useBaseUrl('/');
const currentPath = useLocation().pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
const shouldRenderAlternateLink = currentPath && currentPath !== '404';
const { pathname } = useLocation();
const currentPath = pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
const allDocsData = useAllDocsData();
const isVersionedPage = Object.values(allDocsData).some(
(pluginData) => pluginData.versions.some((version) => !version.isLast && pathname.startsWith(version.path)),
);

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

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

Expand Down