@apify/docs-theme 1.0.269 → 1.0.270
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
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
import Link from '@docusaurus/Link';
|
|
2
2
|
import { useLocation } from '@docusaurus/router';
|
|
3
|
-
import {
|
|
4
|
-
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
5
|
-
import IconHome from '@theme/Icon/Home';
|
|
3
|
+
import { useThemeConfig } from '@docusaurus/theme-common';
|
|
6
4
|
import React from 'react';
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
function isItemActive(item, pathname) {
|
|
7
|
+
if (item.activeBaseRegex) {
|
|
8
|
+
return new RegExp(item.activeBaseRegex).test(pathname);
|
|
9
|
+
}
|
|
10
|
+
if (item.activeBasePath) {
|
|
11
|
+
const basePath = `/${item.activeBasePath.replace(/^\//, '')}`;
|
|
12
|
+
return pathname === basePath || pathname.startsWith(`${basePath}/`);
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
9
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The docs have no single root page, so instead of a home icon the first
|
|
19
|
+
* breadcrumb shows the top navigation item selected for the current page.
|
|
20
|
+
*/
|
|
10
21
|
export default function HomeBreadcrumbItem() {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
const { pathname } = useLocation();
|
|
23
|
+
const { navbar } = useThemeConfig();
|
|
24
|
+
|
|
25
|
+
// When several items match (e.g. Integrations and MCP), the first one in navbar order wins.
|
|
26
|
+
const activeItem = navbar.items.find(
|
|
27
|
+
(item) => item.label && (item.href || item.to) && isItemActive(item, pathname),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (!activeItem) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
15
33
|
|
|
16
34
|
return (
|
|
17
35
|
<li className="breadcrumbs__item">
|
|
36
|
+
{/* The item href is absolute, so pass its target through - Link would default it to _blank. */}
|
|
18
37
|
<Link
|
|
19
|
-
aria-label={translate({
|
|
20
|
-
id: 'theme.docs.breadcrumbs.home',
|
|
21
|
-
message: 'Home page',
|
|
22
|
-
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
23
|
-
})}
|
|
24
38
|
className="breadcrumbs__link"
|
|
25
|
-
href={
|
|
39
|
+
href={activeItem.href ?? activeItem.to}
|
|
40
|
+
target={activeItem.target ?? '_self'}
|
|
41
|
+
rel={activeItem.rel}
|
|
26
42
|
>
|
|
27
|
-
|
|
43
|
+
{activeItem.label}
|
|
28
44
|
</Link>
|
|
29
45
|
</li>
|
|
30
46
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Link from '@docusaurus/Link';
|
|
2
2
|
import { useSidebarBreadcrumbs } from '@docusaurus/plugin-content-docs/client';
|
|
3
3
|
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
4
|
-
import { useHomePageRoute } from '@docusaurus/theme-common/internal';
|
|
5
4
|
import { translate } from '@docusaurus/Translate';
|
|
6
5
|
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
|
|
7
6
|
import clsx from 'clsx';
|
|
@@ -54,7 +53,6 @@ function BreadcrumbsItem({ children, active, index, addMicrodata }) {
|
|
|
54
53
|
|
|
55
54
|
export default function DocBreadcrumbs() {
|
|
56
55
|
const breadcrumbs = useSidebarBreadcrumbs()?.slice(0, -1);
|
|
57
|
-
const homePageRoute = useHomePageRoute();
|
|
58
56
|
if (!breadcrumbs || breadcrumbs.length === 0) {
|
|
59
57
|
return null;
|
|
60
58
|
}
|
|
@@ -68,7 +66,7 @@ export default function DocBreadcrumbs() {
|
|
|
68
66
|
})}
|
|
69
67
|
>
|
|
70
68
|
<ul className="breadcrumbs" itemScope itemType="https://schema.org/BreadcrumbList">
|
|
71
|
-
|
|
69
|
+
<HomeBreadcrumbItem />
|
|
72
70
|
{breadcrumbs.map((item, idx) => {
|
|
73
71
|
// const isLast = idx === breadcrumbs.length - 1;
|
|
74
72
|
const isLast = false;
|