-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathindex.jsx
More file actions
44 lines (40 loc) · 1.73 KB
/
index.jsx
File metadata and controls
44 lines (40 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Head from '@docusaurus/Head';
import { useLocation } from '@docusaurus/router';
import { isRegexpStringMatch } from '@docusaurus/theme-common';
// 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 { usePluginData } from '@docusaurus/useGlobalData';
import React from 'react';
export default function LayoutWrapper(props) {
const { options } = usePluginData('@apify/docs-theme');
const baseUrl = useBaseUrl('/');
const location = useLocation();
const currentPath = location.pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
const shouldRenderAlternateLink = currentPath && currentPath !== '404';
const alternateMarkdownLink = useBaseUrl(`/${currentPath}.md`, { absolute: true });
const subNavbars = options.subNavbars ?? (options.subNavbar ? [options.subNavbar] : []);
const hasActiveSubNavbar = subNavbars.some(
(nav) => !nav.pathRegex || isRegexpStringMatch(nav.pathRegex, location.pathname),
);
return (
<>
<Head>
{
shouldRenderAlternateLink
? <link rel="alternate" type="text/markdown" href={alternateMarkdownLink}/>
: null
}
</Head>
<div
style={{
'--ifm-navbar-height': hasActiveSubNavbar && !currentPath.startsWith('api/v2') ? '126px' : '68px',
margin: 0,
padding: 0,
boxSizing: 'border-box',
}}>
<Layout {...props} />
</div>
</>
);
}