@apify/docs-theme 1.0.60 → 1.0.62

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,24 +1,32 @@
1
1
  {
2
- "name": "@apify/docs-theme",
3
- "version": "1.0.60",
4
- "description": "",
5
- "main": "./src/index.js",
6
- "files": [
7
- "src",
8
- "types",
9
- "static"
10
- ],
11
- "scripts": {
12
- "test": "echo \"Error: no test specified\" && exit 1",
13
- "build": "echo 'Building @apify/docs-theme!'"
14
- },
15
- "keywords": [],
16
- "author": "",
17
- "license": "ISC",
18
- "dependencies": {
19
- "@docusaurus/theme-common": "^2.2.0",
20
- "axios": "^1.3.1",
21
- "babel-loader": "^9.1.0",
22
- "prism-react-renderer": "^1.3.5"
23
- }
2
+ "name": "@apify/docs-theme",
3
+ "version": "1.0.62",
4
+ "description": "",
5
+ "main": "./src/index.js",
6
+ "files": [
7
+ "src",
8
+ "types",
9
+ "static"
10
+ ],
11
+ "scripts": {
12
+ "test": "echo \"Error: no test specified\" && exit 1",
13
+ "build": "echo 'Building @apify/docs-theme!'"
14
+ },
15
+ "keywords": [],
16
+ "author": "",
17
+ "license": "ISC",
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "dependencies": {
22
+ "@docusaurus/theme-common": "^2.3.1",
23
+ "axios": "^1.3.1",
24
+ "babel-loader": "^9.1.0",
25
+ "prism-react-renderer": "^1.3.5"
26
+ },
27
+ "peerDependencies": {
28
+ "@docsearch/react": "*",
29
+ "react": "*",
30
+ "react-dom": "*"
31
+ }
24
32
  }
package/src/config.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable global-require */
1
2
  const absoluteUrl = process.env.LOCAL ? 'http://docs.apify.loc' : 'https://docs.apify.com';
2
3
 
3
4
  const themeConfig = ({
package/src/markdown.js CHANGED
@@ -20,7 +20,7 @@ function pushHeadings(changelog) {
20
20
  }
21
21
 
22
22
  function linkUsers(changelog) {
23
- return changelog.replaceAll(/^\s*[^#].*@([a-zA-Z0-9-]+)/g, '[@$1](https://github.com/$1)');
23
+ return changelog.replaceAll(/@([a-zA-Z0-9-]+)/g, '[@$1](https://github.com/$1)');
24
24
  }
25
25
 
26
26
  function linkPRs(changelog) {
@@ -9,7 +9,7 @@ import styles from './styles.module.css';
9
9
  function ColorModeToggle({
10
10
  className,
11
11
  value,
12
- onChange
12
+ onChange,
13
13
  }) {
14
14
  const isBrowser = useIsBrowser();
15
15
  const title = translate(
@@ -39,7 +39,9 @@ function Footer() {
39
39
  </div>
40
40
  <div className="row padding-vert--md padding-top--lg">
41
41
  <div className="col padding-vert--md col--6">
42
- <div className={styles.footerLogo}></div>
42
+ <a href="https://apify.com" target={'_blank'} rel={'dofollow noreferrer'}>
43
+ <span className={styles.footerLogo}></span>
44
+ </a>
43
45
  </div>
44
46
  </div>
45
47
  </div>
@@ -45,6 +45,7 @@
45
45
  }
46
46
 
47
47
  .footerLogo {
48
+ display: inline-block;
48
49
  width: 90px;
49
50
  height: 24px;
50
51
  background-image: url('/img/footer-apify-logo-black.svg');
@@ -54,3 +55,5 @@
54
55
  html[data-theme='dark'] .footerLogo {
55
56
  background-image: url('/img/footer-apify-logo-white.svg');
56
57
  }
58
+
59
+ /** dummy comment just to trigger theme publishing 2 */
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  import React from 'react';
2
3
 
3
4
  function IconDarkMode(props) {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  import React from 'react';
2
3
 
3
4
  function IconLightMode(props) {
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import Link from '@docusaurus/Link';
3
+ import { isDifferentInstance } from '../../utils';
4
+
5
+ export default function MDXA(props) {
6
+ if (props.href && isDifferentInstance(props.href)) {
7
+ return <a {...props} onClick={((e) => {
8
+ e.preventDefault();
9
+ window.location.assign(props.href);
10
+ })}>
11
+ {props.children}
12
+ </a>;
13
+ }
14
+
15
+ return <Link {...props} />;
16
+ }
@@ -80,6 +80,7 @@ export default function NavbarNavLink({
80
80
  to={toUrl}
81
81
  isNavLink
82
82
  {...((activeBasePath || activeBaseRegex) && {
83
+ // eslint-disable-next-line no-shadow
83
84
  isActive: (_match, location) => (activeBaseRegex
84
85
  ? isRegexpStringMatch(activeBaseRegex, location.pathname) || dropDownHasActiveItem
85
86
  : location.pathname.startsWith(activeBaseUrl)),
@@ -0,0 +1,192 @@
1
+ /* eslint-disable operator-linebreak,import/no-extraneous-dependencies */
2
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
3
+ import { DocSearchButton, useDocSearchKeyboardEvents } from '@docsearch/react';
4
+ import Head from '@docusaurus/Head';
5
+ import Link from '@docusaurus/Link';
6
+ import { useSearchPage } from '@docusaurus/theme-common/internal';
7
+ import {
8
+ useAlgoliaContextualFacetFilters,
9
+ useSearchResultUrlProcessor,
10
+ } from '@docusaurus/theme-search-algolia/client';
11
+ import Translate from '@docusaurus/Translate';
12
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
13
+ import { createPortal } from 'react-dom';
14
+ import translations from '@theme/SearchTranslations';
15
+
16
+ let DocSearchModal = null;
17
+
18
+ function A(props) {
19
+ return <Link {...props} onClick={((e) => {
20
+ e.preventDefault();
21
+ window.location.assign(props.href || props.to);
22
+ })}>
23
+ {props.children}
24
+ </Link>;
25
+ }
26
+
27
+ function Hit({ hit, children }) {
28
+ return <A to={hit.url}>{children}</A>;
29
+ }
30
+
31
+ function ResultsFooter({ state, onClose }) {
32
+ const { generateSearchPageLink } = useSearchPage();
33
+ return (
34
+ <A to={generateSearchPageLink(state.query)} onClick={onClose}>
35
+ <Translate
36
+ id="theme.SearchBar.seeAll"
37
+ values={{ count: state.context.nbHits }}>
38
+ {'See all {count} results'}
39
+ </Translate>
40
+ </A>
41
+ );
42
+ }
43
+
44
+ function mergeFacetFilters(f1, f2) {
45
+ const normalize = (f) => (typeof f === 'string' ? [f] : f);
46
+ return [...normalize(f1), ...normalize(f2)];
47
+ }
48
+
49
+ function DocSearch({ contextualSearch, externalUrlRegex, ...props }) {
50
+ const { siteMetadata } = useDocusaurusContext();
51
+ const processSearchResultUrl = useSearchResultUrlProcessor();
52
+ const contextualSearchFacetFilters = useAlgoliaContextualFacetFilters();
53
+ const configFacetFilters = props.searchParameters?.facetFilters ?? [];
54
+ const facetFilters = contextualSearch
55
+ ? // Merge contextual search filters with config filters
56
+ mergeFacetFilters(contextualSearchFacetFilters, configFacetFilters)
57
+ : // ... or use config facetFilters
58
+ configFacetFilters;
59
+ // We let user override default searchParameters if she wants to
60
+ const searchParameters = {
61
+ ...props.searchParameters,
62
+ facetFilters,
63
+ };
64
+ const searchContainer = useRef(null);
65
+ const searchButtonRef = useRef(null);
66
+ const [isOpen, setIsOpen] = useState(false);
67
+ const [initialQuery, setInitialQuery] = useState(undefined);
68
+ const importDocSearchModalIfNeeded = useCallback(() => {
69
+ if (DocSearchModal) {
70
+ return Promise.resolve();
71
+ }
72
+ return Promise.all([
73
+ import('@docsearch/react/modal'),
74
+ import('@docsearch/react/style'),
75
+ import('./styles.css'),
76
+ ]).then(([{ DocSearchModal: Modal }]) => {
77
+ DocSearchModal = Modal;
78
+ });
79
+ }, []);
80
+ const onOpen = useCallback(() => {
81
+ importDocSearchModalIfNeeded().then(() => {
82
+ searchContainer.current = document.createElement('div');
83
+ document.body.insertBefore(
84
+ searchContainer.current,
85
+ document.body.firstChild,
86
+ );
87
+ setIsOpen(true);
88
+ });
89
+ }, [importDocSearchModalIfNeeded, setIsOpen]);
90
+ const onClose = useCallback(() => {
91
+ setIsOpen(false);
92
+ searchContainer.current?.remove();
93
+ }, [setIsOpen]);
94
+ const onInput = useCallback(
95
+ (event) => {
96
+ importDocSearchModalIfNeeded().then(() => {
97
+ setIsOpen(true);
98
+ setInitialQuery(event.key);
99
+ });
100
+ },
101
+ [importDocSearchModalIfNeeded, setIsOpen, setInitialQuery],
102
+ );
103
+ const navigator = useRef({
104
+ navigate({ itemUrl }) {
105
+ window.location.href = itemUrl;
106
+ },
107
+ }).current;
108
+ const { siteConfig } = useDocusaurusContext();
109
+ const transformItems = useRef((items) => (props.transformItems
110
+ ? // Custom transformItems
111
+ props.transformItems(items)
112
+ : // Default transformItems
113
+ items.map((item) => ({
114
+ ...item,
115
+ url: processSearchResultUrl(item.url).replace(new RegExp(`^${siteConfig.baseUrl}`), '/'),
116
+ }))),
117
+ ).current;
118
+ const resultsFooterComponent = useMemo(
119
+ () =>
120
+ // eslint-disable-next-line react/no-unstable-nested-components,react/display-name,implicit-arrow-linebreak
121
+ (footerProps) => <ResultsFooter {...footerProps} onClose={onClose}/>,
122
+ [onClose],
123
+ );
124
+ const transformSearchClient = useCallback(
125
+ (searchClient) => {
126
+ searchClient.addAlgoliaAgent(
127
+ 'docusaurus',
128
+ siteMetadata.docusaurusVersion,
129
+ );
130
+ return searchClient;
131
+ },
132
+ [siteMetadata.docusaurusVersion],
133
+ );
134
+ useDocSearchKeyboardEvents({
135
+ isOpen,
136
+ onOpen,
137
+ onClose,
138
+ onInput,
139
+ searchButtonRef,
140
+ });
141
+ return (
142
+ <>
143
+ <Head>
144
+ {/* This hints the browser that the website will load data from Algolia,
145
+ and allows it to preconnect to the DocSearch cluster. It makes the first
146
+ query faster, especially on mobile. */}
147
+ <link
148
+ rel="preconnect"
149
+ href={`https://${props.appId}-dsn.algolia.net`}
150
+ crossOrigin="anonymous"
151
+ />
152
+ </Head>
153
+
154
+ <DocSearchButton
155
+ onTouchStart={importDocSearchModalIfNeeded}
156
+ onFocus={importDocSearchModalIfNeeded}
157
+ onMouseOver={importDocSearchModalIfNeeded}
158
+ onClick={onOpen}
159
+ ref={searchButtonRef}
160
+ translations={translations.button}
161
+ />
162
+
163
+ {isOpen
164
+ && DocSearchModal
165
+ && searchContainer.current
166
+ && createPortal(
167
+ <DocSearchModal
168
+ onClose={onClose}
169
+ initialScrollY={window.scrollY}
170
+ initialQuery={initialQuery}
171
+ navigator={navigator}
172
+ transformItems={transformItems}
173
+ hitComponent={Hit}
174
+ transformSearchClient={transformSearchClient}
175
+ {...(props.searchPagePath && {
176
+ resultsFooterComponent,
177
+ })}
178
+ {...props}
179
+ searchParameters={searchParameters}
180
+ placeholder={translations.placeholder}
181
+ translations={translations.modal}
182
+ />,
183
+ searchContainer.current,
184
+ )}
185
+ </>
186
+ );
187
+ }
188
+
189
+ export default function SearchBar() {
190
+ const { siteConfig } = useDocusaurusContext();
191
+ return <DocSearch {...siteConfig.themeConfig.algolia} />;
192
+ }
@@ -0,0 +1,14 @@
1
+ :root {
2
+ --docsearch-primary-color: var(--ifm-color-primary);
3
+ --docsearch-text-color: var(--ifm-font-color-base);
4
+ }
5
+
6
+ .DocSearch-Button {
7
+ margin: 0;
8
+ transition: all var(--ifm-transition-fast)
9
+ var(--ifm-transition-timing-default);
10
+ }
11
+
12
+ .DocSearch-Container {
13
+ z-index: calc(var(--ifm-z-index-fixed) + 1);
14
+ }
@@ -536,7 +536,6 @@ div[class*="searchBox"] {
536
536
  align-items: center;
537
537
  }
538
538
 
539
-
540
539
  @media (min-width: 480px) {
541
540
  .navbar__logo {
542
541
  display: initial;
package/src/theme.js CHANGED
@@ -85,7 +85,7 @@ function theme(
85
85
  title: Changelog
86
86
  sidebar_label: Changelog
87
87
  ---
88
- It seems that the changelog is not available.
88
+ It seems that the changelog is not available.
89
89
  This either means that your Docusaurus setup is misconfigured, or that your GitHub repository contains no releases yet.
90
90
  `);
91
91
  }
@@ -96,6 +96,7 @@ This either means that your Docusaurus setup is misconfigured, or that your GitH
96
96
  await copyChangelogFromReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
97
97
  }
98
98
  } catch (e) {
99
+ // eslint-disable-next-line no-console
99
100
  console.warn(`Changelog page could not be initialized: ${e.message}`);
100
101
  }
101
102
  },
package/src/utils.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @param {string} input
3
+ */
4
+ export function isDifferentInstance(input) {
5
+ const simplified = input.startsWith('/') ? input.slice(1) : input;
6
+
7
+ const instanceUrls = [
8
+ 'api/client',
9
+ 'sdk',
10
+ 'cli',
11
+ ];
12
+
13
+ return instanceUrls.some((url) => simplified.startsWith(url));
14
+ }
package/types/index.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @typedef {{
3
- * subNavbar: {
4
- * title: string,
5
- * items: any[]
6
- * }
7
- * }} ThemeOptions
8
- */
9
-
10
- module.exports = {
11
- types: {},
12
- };