@apify/docs-theme 1.0.95 → 1.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/theme/ColorModeToggle/index.jsx +1 -0
- package/src/theme/DocBreadcrumbs/Items/Home/index.js +29 -0
- package/src/theme/DocBreadcrumbs/Items/Home/styles.module.css +7 -0
- package/src/theme/DocBreadcrumbs/index.js +96 -0
- package/src/theme/DocBreadcrumbs/styles.module.css +4 -0
- package/src/theme/DocSidebarItem/Link/index.jsx +1 -0
- package/src/theme/Footer/index.jsx +1 -1
- package/src/theme/RunnableCodeBlock/RunnableCodeBlock.jsx +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Link from '@docusaurus/Link';
|
|
3
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
4
|
+
import { useLocation } from '@docusaurus/router';
|
|
5
|
+
import { translate } from '@docusaurus/Translate';
|
|
6
|
+
import IconHome from '@theme/Icon/Home';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
|
|
9
|
+
export default function HomeBreadcrumbItem() {
|
|
10
|
+
const baseUrl = useBaseUrl('/');
|
|
11
|
+
const currentPath = useLocation().pathname.replace(new RegExp(`^${baseUrl}`), '');
|
|
12
|
+
const rootSection = useBaseUrl(currentPath.split('/')[0]);
|
|
13
|
+
const homeHref = baseUrl === '/' ? rootSection : baseUrl;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<li className="breadcrumbs__item">
|
|
17
|
+
<Link
|
|
18
|
+
aria-label={translate({
|
|
19
|
+
id: 'theme.docs.breadcrumbs.home',
|
|
20
|
+
message: 'Home page',
|
|
21
|
+
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
22
|
+
})}
|
|
23
|
+
className="breadcrumbs__link"
|
|
24
|
+
href={homeHref}>
|
|
25
|
+
<IconHome className={styles.breadcrumbHomeIcon} />
|
|
26
|
+
</Link>
|
|
27
|
+
</li>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
5
|
+
import {
|
|
6
|
+
useSidebarBreadcrumbs,
|
|
7
|
+
useHomePageRoute,
|
|
8
|
+
} from '@docusaurus/theme-common/internal';
|
|
9
|
+
import Link from '@docusaurus/Link';
|
|
10
|
+
import { translate } from '@docusaurus/Translate';
|
|
11
|
+
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
|
|
12
|
+
import styles from './styles.module.css';
|
|
13
|
+
|
|
14
|
+
// TODO move to design system folder
|
|
15
|
+
function BreadcrumbsItemLink({ children, href, isLast }) {
|
|
16
|
+
const className = 'breadcrumbs__link';
|
|
17
|
+
if (isLast) {
|
|
18
|
+
return (
|
|
19
|
+
<span className={className} itemProp="name">
|
|
20
|
+
{children}
|
|
21
|
+
</span>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return href ? (
|
|
25
|
+
<Link className={className} href={href} itemProp="item">
|
|
26
|
+
<span itemProp="name">{children}</span>
|
|
27
|
+
</Link>
|
|
28
|
+
) : (
|
|
29
|
+
// TODO Google search console doesn't like breadcrumb items without href.
|
|
30
|
+
// The schema doesn't seem to require `id` for each `item`, although Google
|
|
31
|
+
// insist to infer one, even if it's invalid. Removing `itemProp="item
|
|
32
|
+
// name"` for now, since I don't know how to properly fix it.
|
|
33
|
+
// See https://github.com/facebook/docusaurus/issues/7241
|
|
34
|
+
<span className={className}>{children}</span>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// TODO move to design system folder
|
|
39
|
+
function BreadcrumbsItem({ children, active, index, addMicrodata }) {
|
|
40
|
+
return (
|
|
41
|
+
<li
|
|
42
|
+
{...(addMicrodata && {
|
|
43
|
+
itemScope: true,
|
|
44
|
+
itemProp: 'itemListElement',
|
|
45
|
+
itemType: 'https://schema.org/ListItem',
|
|
46
|
+
})}
|
|
47
|
+
className={clsx('breadcrumbs__item', {
|
|
48
|
+
'breadcrumbs__item--active': active,
|
|
49
|
+
})}>
|
|
50
|
+
{children}
|
|
51
|
+
<meta itemProp="position" content={String(index + 1)}/>
|
|
52
|
+
</li>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default function DocBreadcrumbs() {
|
|
57
|
+
const breadcrumbs = useSidebarBreadcrumbs().slice(0, -1);
|
|
58
|
+
const homePageRoute = useHomePageRoute();
|
|
59
|
+
if (!breadcrumbs || breadcrumbs.length === 0) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return (
|
|
63
|
+
<nav
|
|
64
|
+
className={clsx(
|
|
65
|
+
ThemeClassNames.docs.docBreadcrumbs,
|
|
66
|
+
styles.breadcrumbsContainer,
|
|
67
|
+
)}
|
|
68
|
+
aria-label={translate({
|
|
69
|
+
id: 'theme.docs.breadcrumbs.navAriaLabel',
|
|
70
|
+
message: 'Breadcrumbs',
|
|
71
|
+
description: 'The ARIA label for the breadcrumbs',
|
|
72
|
+
})}>
|
|
73
|
+
<ul
|
|
74
|
+
className="breadcrumbs"
|
|
75
|
+
itemScope
|
|
76
|
+
itemType="https://schema.org/BreadcrumbList">
|
|
77
|
+
{homePageRoute && <HomeBreadcrumbItem/>}
|
|
78
|
+
{breadcrumbs.map((item, idx) => {
|
|
79
|
+
// const isLast = idx === breadcrumbs.length - 1;
|
|
80
|
+
const isLast = false;
|
|
81
|
+
return (
|
|
82
|
+
<BreadcrumbsItem
|
|
83
|
+
key={idx}
|
|
84
|
+
active={isLast}
|
|
85
|
+
index={idx}
|
|
86
|
+
addMicrodata={!!item.href}>
|
|
87
|
+
<BreadcrumbsItemLink href={item.href} isLast={isLast}>
|
|
88
|
+
{item.label}
|
|
89
|
+
</BreadcrumbsItemLink>
|
|
90
|
+
</BreadcrumbsItem>
|
|
91
|
+
);
|
|
92
|
+
})}
|
|
93
|
+
</ul>
|
|
94
|
+
</nav>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
import clsx from 'clsx';
|
|
4
4
|
import { useThemeConfig } from '@docusaurus/theme-common';
|
|
5
5
|
import LinkItem from '@theme/Footer/LinkItem';
|
|
6
6
|
import styles from './index.module.css';
|