@apify/docs-theme 1.0.2 → 1.0.3

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.
Files changed (36) hide show
  1. package/package.json +6 -5
  2. package/{img → src/img}/footer-apify-logo.svg +0 -0
  3. package/{img → src/img}/footer-open-source.svg +0 -0
  4. package/src/index.js +40 -0
  5. package/src/theme/ColorModeToggle/index.jsx +64 -0
  6. package/{theme → src/theme}/ColorModeToggle/styles.module.css +0 -0
  7. package/src/theme/DocSidebarItem/Link/index.jsx +62 -0
  8. package/src/theme/DocSidebarItem/Link/styles.module.css +3 -0
  9. package/src/theme/Footer/index.jsx +72 -0
  10. package/{theme → src/theme}/Footer/index.module.css +0 -0
  11. package/src/theme/Icon/DarkMode/index.jsx +11 -0
  12. package/src/theme/Icon/LightMode/index.jsx +28 -0
  13. package/src/theme/Navbar/Content/index.jsx +95 -0
  14. package/{theme → src/theme}/Navbar/Content/styles.module.css +0 -0
  15. package/src/theme/NavbarItem/ComponentTypes.jsx +101 -0
  16. package/src/theme/NavbarItem/NavbarNavLink.jsx +69 -0
  17. package/src/theme/NotFound.jsx +77 -0
  18. package/src/theme/custom.css +378 -0
  19. package/index.d.ts +0 -9
  20. package/index.js +0 -20
  21. package/theme/ColorModeToggle/index.d.ts +0 -8
  22. package/theme/ColorModeToggle/index.js +0 -38
  23. package/theme/Footer/index.d.ts +0 -4
  24. package/theme/Footer/index.js +0 -49
  25. package/theme/Icon/DarkMode/index.d.ts +0 -4
  26. package/theme/Icon/DarkMode/index.js +0 -11
  27. package/theme/Icon/LightMode/index.d.ts +0 -4
  28. package/theme/Icon/LightMode/index.js +0 -23
  29. package/theme/Navbar/Content/index.d.ts +0 -1
  30. package/theme/Navbar/Content/index.js +0 -60
  31. package/theme/NavbarItem/ComponentTypes.d.ts +0 -20
  32. package/theme/NavbarItem/ComponentTypes.js +0 -64
  33. package/theme/NavbarItem/NavbarNavLink.d.ts +0 -11
  34. package/theme/NavbarItem/NavbarNavLink.js +0 -42
  35. package/theme/NotFound.d.ts +0 -1
  36. package/theme/NotFound.js +0 -69
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@apify/docs-theme",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
- "main": "./index.js",
5
+ "main": "./src/index.js",
6
+ "files": [
7
+ "src"
8
+ ],
6
9
  "scripts": {
7
10
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "rimraf ./dist && tsc && npm run copyStyles && npm run copyImages",
9
- "copyStyles": "rsync -a -m --include '*/' --include '*.css' --exclude '*' ./src/theme/ ./dist/theme",
10
- "copyImages": "cp -r src/img ./dist/img"
11
+ "build": "echo 'Building @apify/docs-theme!'"
11
12
  },
12
13
  "keywords": [],
13
14
  "author": "",
File without changes
File without changes
package/src/index.js ADDED
@@ -0,0 +1,40 @@
1
+ function theme(
2
+ context,
3
+ options,
4
+ ) {
5
+ return {
6
+ name: '@apify/docs-theme',
7
+ getThemePath() {
8
+ return '../src/theme';
9
+ },
10
+ getTypeScriptThemePath() {
11
+ return '../src/theme';
12
+ },
13
+ contentLoaded({ actions }) {
14
+ const { setGlobalData } = actions;
15
+ setGlobalData({
16
+ options,
17
+ });
18
+ },
19
+ getClientModules() {
20
+ return [
21
+ require.resolve('./theme/custom.css'),
22
+ ];
23
+ },
24
+ configureWebpack() {
25
+ return {
26
+ module: {
27
+ rules: [
28
+ {
29
+ test: /\.(js|jsx)$/,
30
+ exclude: /node_modules/,
31
+ use: { loader: 'babel-loader' },
32
+ },
33
+ ],
34
+ },
35
+ };
36
+ },
37
+ };
38
+ }
39
+
40
+ exports.default = theme;
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import useIsBrowser from '@docusaurus/useIsBrowser';
4
+ import { translate } from '@docusaurus/Translate';
5
+ import IconLightMode from '../Icon/LightMode';
6
+ import IconDarkMode from '../Icon/DarkMode';
7
+ import styles from './styles.module.css';
8
+
9
+ function ColorModeToggle({
10
+ className,
11
+ value,
12
+ onChange
13
+ }) {
14
+ const isBrowser = useIsBrowser();
15
+ const title = translate(
16
+ {
17
+ message: 'Switch between dark and light mode (currently {mode})',
18
+ id: 'theme.colorToggle.ariaLabel',
19
+ description: 'The ARIA label for the navbar color mode toggle',
20
+ },
21
+ {
22
+ mode:
23
+ value === 'dark'
24
+ ? translate({
25
+ message: 'dark mode',
26
+ id: 'theme.colorToggle.ariaLabel.mode.dark',
27
+ description: 'The name for the dark color mode',
28
+ })
29
+ : translate({
30
+ message: 'light mode',
31
+ id: 'theme.colorToggle.ariaLabel.mode.light',
32
+ description: 'The name for the light color mode',
33
+ }),
34
+ },
35
+ );
36
+ return (
37
+ <div className={clsx(styles.toggle, className)}>
38
+ <button
39
+ className={clsx(
40
+ 'clean-btn',
41
+ styles.toggleButton,
42
+ !isBrowser && styles.toggleButtonDisabled,
43
+ )}
44
+ type="button"
45
+ onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
46
+ disabled={!isBrowser}
47
+ title={title}
48
+ aria-label={title}>
49
+ <span>
50
+ <IconLightMode
51
+ className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
52
+ width={14} height={14}
53
+ />
54
+ <IconDarkMode
55
+ className={clsx(styles.toggleIcon, styles.darkToggleIcon)}
56
+ width={14} height={14}
57
+ />
58
+ </span>
59
+ </button>
60
+ </div>
61
+ );
62
+ }
63
+
64
+ export default React.memo(ColorModeToggle);
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import { ThemeClassNames } from '@docusaurus/theme-common';
4
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5
+ import { isActiveSidebarItem } from '@docusaurus/theme-common/internal';
6
+ import Link from '@docusaurus/Link';
7
+ import isInternalUrl from '@docusaurus/isInternalUrl';
8
+ import IconExternalLink from '@theme/Icon/ExternalLink';
9
+ import styles from './styles.module.css';
10
+
11
+ export default function DocSidebarItemLink({
12
+ item,
13
+ onItemClick,
14
+ activePath,
15
+ level,
16
+ index,
17
+ ...props
18
+ }) {
19
+ const {
20
+ href,
21
+ label,
22
+ className,
23
+ autoAddBaseUrl,
24
+ } = item;
25
+ const isActive = isActiveSidebarItem(item, activePath);
26
+ const isInternalLink = isInternalUrl(href);
27
+ const baseUrl = useDocusaurusContext().siteConfig.url;
28
+
29
+ if (href.startsWith(baseUrl)) {
30
+ props.target = '_self';
31
+ }
32
+
33
+ return (
34
+ <li
35
+ className={clsx(
36
+ ThemeClassNames.docs.docSidebarItemLink,
37
+ ThemeClassNames.docs.docSidebarItemLinkLevel(level),
38
+ 'menu__list-item',
39
+ className,
40
+ )}
41
+ key={label}>
42
+ <Link
43
+ className={clsx(
44
+ 'menu__link',
45
+ !isInternalLink && styles.menuExternalLink,
46
+ {
47
+ 'menu__link--active': isActive,
48
+ },
49
+ )}
50
+ autoAddBaseUrl={autoAddBaseUrl}
51
+ aria-current={isActive ? 'page' : undefined}
52
+ to={href}
53
+ {...(isInternalLink && {
54
+ onClick: onItemClick ? () => onItemClick(item) : undefined,
55
+ })}
56
+ {...props}>
57
+ {label}
58
+ {!isInternalLink && <IconExternalLink />}
59
+ </Link>
60
+ </li>
61
+ );
62
+ }
@@ -0,0 +1,3 @@
1
+ .menuExternalLink {
2
+ align-items: center;
3
+ }
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ import { useThemeConfig } from '@docusaurus/theme-common';
5
+ import LinkItem from '@theme/Footer/LinkItem';
6
+ import styles from './index.module.css';
7
+
8
+ function FooterLinksColumn({ column }) {
9
+ return (
10
+ <>
11
+ <div className={styles.footerTitle}>{column.title}</div>
12
+ <ul className={clsx(styles.footerItem, 'clean-list')}>
13
+ {column.items.map((item, i) => (
14
+ <li key={i} className="footer__item">
15
+ <LinkItem item={item} />
16
+ </li>
17
+ ))}
18
+ </ul>
19
+ </>
20
+ );
21
+ }
22
+
23
+ function Footer() {
24
+ const { footer } = useThemeConfig();
25
+ if (!footer) {
26
+ return null;
27
+ }
28
+ const { links, style } = footer;
29
+ const OpenSourceIcon = require('../../img/footer-open-source.svg').default;
30
+ const ApifyLogo = require('../../img/footer-apify-logo.svg').default;
31
+ return (
32
+ <footer className={clsx(styles.footer, style)}>
33
+ <div className="container padding-horiz--lg">
34
+ <div className="row">
35
+ <div className="col col--5">
36
+ <div className="row">
37
+ <div className="col col--6">
38
+ <FooterLinksColumn column={links[0]} />
39
+ </div>
40
+ <div className="col col--6">
41
+ <FooterLinksColumn column={links[1]} />
42
+ </div>
43
+ </div>
44
+ </div>
45
+ <div className="col col--7">
46
+ <div className="row">
47
+ <div className="col col--3 col--offset-9">
48
+ <FooterLinksColumn column={links[2]} />
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <div className="row padding-vert--md padding-top--lg">
54
+ <div className="col padding-vert--md col--6">
55
+ <div className={styles.freeAndOpenSource}>
56
+ <OpenSourceIcon className={styles.alignMiddle} />
57
+ <span className={styles.alignMiddle}>Apify SDK is free and open source</span>
58
+ </div>
59
+ </div>
60
+ <div className="col padding-vert--md col--6 text--right">
61
+ <span className={styles.builtBy}>
62
+ <span className={styles.alignMiddle}>Built by</span>
63
+ <ApifyLogo className={styles.alignMiddle} />
64
+ </span>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </footer>
69
+ );
70
+ }
71
+
72
+ export default React.memo(Footer);
File without changes
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+
3
+ function IconDarkMode(props) {
4
+ return (
5
+ <svg viewBox="0 0 13 12" width={14} height={14} {...props}>
6
+ <path d="M10.7001 6.39501C10.6215 7.24611 10.3021 8.05721 9.77927 8.7334C9.25646 9.40959 8.55189 9.92291 7.748 10.2133C6.9441 10.5036 6.07414 10.5591 5.2399 10.3731C4.40565 10.187 3.64164 9.76728 3.03726 9.1629C2.43287 8.55851 2.01312 7.7945 1.8271 6.96026C1.64108 6.12602 1.6965 5.25605 1.98688 4.45216C2.27725 3.64826 2.79056 2.94369 3.46675 2.42088C4.14294 1.89808 4.95404 1.57866 5.80515 1.50001C5.30685 2.17414 5.06707 3.00473 5.12941 3.84071C5.19175 4.6767 5.55208 5.46254 6.14485 6.05531C6.73762 6.64808 7.52346 7.0084 8.35944 7.07074C9.19542 7.13308 10.026 6.8933 10.7001 6.39501Z" stroke="currentColor" fill="transparent" strokeLinecap="round" strokeLinejoin="round"/>
7
+ </svg>
8
+ );
9
+ }
10
+
11
+ export default React.memo(IconDarkMode);
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ function IconLightMode(props) {
4
+ return (
5
+ <svg viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg" width={14} height={14} {...props}>
6
+ <g clipPath="url(#clip0_833_8168)">
7
+ <path
8
+ d="M6.59998 8.49999C7.98069 8.49999 9.09998 7.3807 9.09998 5.99999C9.09998 4.61928 7.98069 3.49999 6.59998 3.49999C5.21926 3.49999 4.09998 4.61928 4.09998 5.99999C4.09998 7.3807 5.21926 8.49999 6.59998 8.49999Z"
9
+ stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
10
+ <path d="M6.59985 0.5V1.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
11
+ <path d="M6.59985 10.5V11.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
12
+ <path d="M2.7099 2.11L3.4199 2.82" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
13
+ <path d="M9.77991 9.17999L10.4899 9.88999" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
14
+ <path d="M1.09998 6H2.09998" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
15
+ <path d="M11.0999 6H12.0999" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
16
+ <path d="M2.7099 9.88999L3.4199 9.17999" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
17
+ <path d="M9.77991 2.82L10.4899 2.11" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
18
+ </g>
19
+ <defs>
20
+ <clipPath id="clip0_833_8168">
21
+ <rect width="12" height="12" fill="white" transform="translate(0.599976)"/>
22
+ </clipPath>
23
+ </defs>
24
+ </svg>
25
+ );
26
+ }
27
+
28
+ export default React.memo(IconLightMode);
@@ -0,0 +1,95 @@
1
+ import React from 'react';
2
+ import { useThemeConfig } from '@docusaurus/theme-common';
3
+ import { usePluginData } from '@docusaurus/useGlobalData';
4
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5
+ import {
6
+ splitNavbarItems,
7
+ } from '@docusaurus/theme-common/internal';
8
+ import NavbarLogo from '@theme/Navbar/Logo';
9
+ import NavbarItem from '@theme/NavbarItem';
10
+ import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
11
+ import NavbarSearch from '@theme/Navbar/Search';
12
+ import SearchBar from '@theme/SearchBar';
13
+ import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
14
+ import styles from './styles.module.css';
15
+
16
+ function NavbarItems({ items }) {
17
+ return (
18
+ <>
19
+ {items.map((item, i) => (
20
+ <NavbarItem {...item} key={i}/>
21
+ ))}
22
+ </>
23
+ );
24
+ }
25
+
26
+ function NavbarContentLayout({
27
+ left,
28
+ right,
29
+ }) {
30
+ return (
31
+ <div className="navbar__inner">
32
+ <div className="navbar__items">{left}</div>
33
+ <div className="navbar__items navbar__items--right">{right}</div>
34
+ </div>
35
+ );
36
+ }
37
+
38
+ function SubNavbar() {
39
+ const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
40
+ const pageTitle = useDocusaurusContext().siteConfig.title;
41
+ return (
42
+ subNavbar ? (
43
+ <div className="navbar__inner">
44
+ <div className="navbar__items">
45
+ <NavbarItems items={[
46
+ {
47
+ label: pageTitle,
48
+ to: '/',
49
+ },
50
+ ...subNavbar,
51
+ ]}/>
52
+ </div>
53
+ </div>
54
+ ) : null
55
+ );
56
+ }
57
+
58
+ export default function NavbarContent() {
59
+ const { navbar: { items } } = useThemeConfig();
60
+ const [leftItems, rightItems] = splitNavbarItems(items);
61
+ const searchBarItem = items.find((item) => item.type === 'search');
62
+ return (
63
+ <div
64
+ style={{
65
+ width: '100%',
66
+ height: '100%',
67
+ alignItems: 'center',
68
+ display: 'flex',
69
+ flexDirection: 'column',
70
+ }}
71
+ >
72
+ <NavbarContentLayout
73
+ left={
74
+ <>
75
+ <NavbarMobileSidebarToggle/>
76
+ <NavbarLogo/>
77
+ <NavbarItems items={leftItems}/>
78
+ </>
79
+ }
80
+ right={
81
+ <>
82
+ <NavbarColorModeToggle className={styles.colorModeToggle}/>
83
+ <NavbarItems items={rightItems}/>
84
+ {!searchBarItem && (
85
+ <NavbarSearch>
86
+ <SearchBar/>
87
+ </NavbarSearch>
88
+ )}
89
+ </>
90
+ }
91
+ />
92
+ <SubNavbar/>
93
+ </div>
94
+ );
95
+ }
@@ -0,0 +1,101 @@
1
+ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
2
+ import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
3
+ import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
4
+ import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
5
+ import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
6
+ import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
7
+ import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
8
+ import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
9
+ import { useDocsVersion, useLayoutDoc } from '@docusaurus/theme-common/internal';
10
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
11
+ import React from 'react';
12
+
13
+ // const versions = require('../../../versions.json');
14
+ //
15
+ // const stable = versions[0];
16
+ const stable = '1';
17
+
18
+ function DocNavbarItem({
19
+ docId,
20
+ label: staticLabel,
21
+ docsPluginId,
22
+ ...props
23
+ }) {
24
+ const doc = useLayoutDoc(docId, docsPluginId);
25
+ // Draft items are not displayed in the navbar.
26
+ if (doc === null) {
27
+ return null;
28
+ }
29
+ return (
30
+ <DefaultNavbarItem
31
+ exact
32
+ {...props}
33
+ label={staticLabel ?? doc.id}
34
+ to={doc.path}
35
+ />
36
+ );
37
+ }
38
+
39
+ function ApiNavbarItem(ctx) {
40
+ let version = {};
41
+
42
+ try {
43
+ // eslint-disable-next-line react-hooks/rules-of-hooks
44
+ version = useDocsVersion();
45
+ } catch {
46
+ version.version = stable;
47
+ }
48
+
49
+ const { siteConfig } = useDocusaurusContext();
50
+
51
+ if (siteConfig.presets[0][1].docs.disableVersioning || version.version === stable) {
52
+ return (
53
+ <DefaultNavbarItem
54
+ exact
55
+ {...ctx}
56
+ label={ctx.label}
57
+ to={`api/${ctx.to}`}
58
+ />
59
+ );
60
+ }
61
+
62
+ // skip changelog button for older versions
63
+ if (+version.version < 3 && ctx.className === 'changelog') {
64
+ return null;
65
+ }
66
+
67
+ // link directly to the old API docs under /docs/x.x/api
68
+ if (+version.version < 3) {
69
+ return (
70
+ <DefaultNavbarItem
71
+ exact
72
+ {...ctx}
73
+ label={ctx.label}
74
+ to={`docs/${version.version === 'current' ? 'next' : version.version}/api/${ctx.to}`}
75
+ />
76
+ );
77
+ }
78
+
79
+ return (
80
+ <DefaultNavbarItem
81
+ exact
82
+ {...ctx}
83
+ label={ctx.label}
84
+ to={`api/${version.version === 'current' ? 'next' : version.version}/${ctx.to}`}
85
+ />
86
+ );
87
+ }
88
+
89
+ const ComponentTypes = {
90
+ 'default': DefaultNavbarItem,
91
+ 'localeDropdown': LocaleDropdownNavbarItem,
92
+ 'search': SearchNavbarItem,
93
+ 'dropdown': DropdownNavbarItem,
94
+ 'html': HtmlNavbarItem,
95
+ 'custom-api': ApiNavbarItem,
96
+ 'doc': DocNavbarItem,
97
+ 'docSidebar': DocSidebarNavbarItem,
98
+ 'docsVersion': DocsVersionNavbarItem,
99
+ 'docsVersionDropdown': DocsVersionDropdownNavbarItem,
100
+ };
101
+ export default ComponentTypes;
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import Link from '@docusaurus/Link';
3
+ import useBaseUrl from '@docusaurus/useBaseUrl';
4
+ import isInternalUrl from '@docusaurus/isInternalUrl';
5
+ import { useLocation } from '@docusaurus/router';
6
+ import { isRegexpStringMatch } from '@docusaurus/theme-common';
7
+
8
+ export default function NavbarNavLink({
9
+ activeBasePath,
10
+ activeBaseRegex,
11
+ to,
12
+ href,
13
+ label,
14
+ html,
15
+ isDropdownLink,
16
+ prependBaseUrlToHref,
17
+ ...props
18
+ }) {
19
+ const location = useLocation();
20
+ // TODO all this seems hacky
21
+ // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
22
+ const toUrl = useBaseUrl(to);
23
+ const activeBaseUrl = useBaseUrl(activeBasePath);
24
+ const normalizedHref = useBaseUrl(href, { forcePrependBaseUrl: true });
25
+ // const isExternalLink = label && href && !isInternalUrl(href);
26
+ const isExternalLink = false;
27
+ // Link content is set through html XOR label
28
+ const linkContentProps = html
29
+ ? { dangerouslySetInnerHTML: { __html: html } }
30
+ : {
31
+ children: (
32
+ <>
33
+ {label}
34
+ {isExternalLink && (
35
+ <IconExternalLink
36
+ {...(isDropdownLink && { width: 12, height: 12 })}
37
+ />
38
+ )}
39
+ </>
40
+ ),
41
+ };
42
+ if (href) {
43
+ return (
44
+ <Link
45
+ href={prependBaseUrlToHref ? normalizedHref : href}
46
+ {...props}
47
+ {...(activeBaseUrl && {
48
+ className: location.pathname.startsWith(`/${activeBasePath}`)
49
+ ? 'navbar__item navbar__link navbar__link--active'
50
+ : 'navbar__item navbar__link',
51
+ })}
52
+ {...linkContentProps}
53
+ />
54
+ );
55
+ }
56
+ return (
57
+ <Link
58
+ to={toUrl}
59
+ isNavLink
60
+ {...((activeBasePath || activeBaseRegex) && {
61
+ isActive: (_match, location) => (activeBaseRegex
62
+ ? isRegexpStringMatch(activeBaseRegex, location.pathname)
63
+ : location.pathname.startsWith(activeBaseUrl)),
64
+ })}
65
+ {...props}
66
+ {...linkContentProps}
67
+ />
68
+ );
69
+ }
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import useBaseUrl from '@docusaurus/useBaseUrl';
3
+ import useIsBrowser from '@docusaurus/useIsBrowser';
4
+ import { PageMetadata } from '@docusaurus/theme-common';
5
+ import Link from '@docusaurus/Link';
6
+ import Layout from '@theme/Layout';
7
+
8
+ export default function NotFound() {
9
+ const redirectedV2Url = useBaseUrl('/docs/api');
10
+ const redirectedV1Url = useBaseUrl('/docs/1.3.1/api');
11
+ const baseUrlForV2Redirect = useBaseUrl(`/docs/2.3/api/`);
12
+ const baseUrlForV1Redirect = useBaseUrl(`/docs/1.3/api/`);
13
+ const isBrowser = useIsBrowser();
14
+
15
+ if (isBrowser) {
16
+ const path = window.location.pathname;
17
+ let href = '';
18
+ let redirect = false;
19
+
20
+ if (path.startsWith(redirectedV2Url)) {
21
+ href = baseUrlForV2Redirect + path.substring(redirectedV2Url.length + 1);
22
+ redirect = true;
23
+ }
24
+
25
+ if (path.match(/\/docs\/2\.\d+\.\d+\/api/)) {
26
+ href = baseUrlForV2Redirect + path.substring(redirectedV1Url.length + 1);
27
+ redirect = true;
28
+ }
29
+
30
+ if (path.match(/\/api\/[12]\.\d+\/\w+/)) {
31
+ const [, v, id] = path.match(/\/api\/([12])\.\d+\/(.*)/);
32
+ href = (v === '1' ? baseUrlForV1Redirect : baseUrlForV2Redirect) + id;
33
+ redirect = true;
34
+ }
35
+
36
+ if (path.match(/\/docs\/[01]\.\d+\.\d+\/api\/(.*)/)) {
37
+ const id = path.match(/\/docs\/[01]\.\d+\.\d+\/api\/(.*)/)[1];
38
+ href = baseUrlForV1Redirect + id;
39
+ redirect = true;
40
+ }
41
+
42
+ if (redirect && window.location.href !== href) {
43
+ window.location.href = href;
44
+ }
45
+ }
46
+
47
+ return (
48
+ <>
49
+ <PageMetadata title={'Page Not Found'} />
50
+ <Layout>
51
+ <main className="container margin-vert--xl">
52
+ <div className="row">
53
+ <div className="col col--6 col--offset-3">
54
+ <h1 className="hero__title">
55
+ Page Not Found
56
+ </h1>
57
+ <p>
58
+ We could not find what you were looking for 😢
59
+ </p>
60
+ <p>
61
+ Recently we <b>released Apify SDK v3 </b>
62
+ and we significantly upgraded the documentation.
63
+ </p>
64
+ <p>
65
+ If you're looking for documentation of <b>Apify SDK v2</b>,
66
+ <Link to={'/docs/2.3/guides/apify-platform'}> you can find it here</Link>.
67
+ </p>
68
+ <p>
69
+ For <b>Apify SDK v3 docs</b>, go to the <Link to={'/'}>homepage</Link>.
70
+ </p>
71
+ </div>
72
+ </div>
73
+ </main>
74
+ </Layout>
75
+ </>
76
+ );
77
+ }