@apify/docs-theme 1.0.70 → 1.0.72

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/docs-theme",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -4,10 +4,7 @@ import { DocSearchButton, useDocSearchKeyboardEvents } from '@docsearch/react';
4
4
  import Head from '@docusaurus/Head';
5
5
  import Link from '@docusaurus/Link';
6
6
  import { useSearchPage } from '@docusaurus/theme-common/internal';
7
- import {
8
- useAlgoliaContextualFacetFilters,
9
- useSearchResultUrlProcessor,
10
- } from '@docusaurus/theme-search-algolia/client';
7
+ import { useAlgoliaContextualFacetFilters } from '@docusaurus/theme-search-algolia/client';
11
8
  import { useActiveDocContext } from '@docusaurus/plugin-content-docs/client';
12
9
  import Translate from '@docusaurus/Translate';
13
10
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
@@ -16,23 +13,33 @@ import translations from '@theme/SearchTranslations';
16
13
 
17
14
  let DocSearchModal = null;
18
15
 
16
+ function useLink(href, baseUrl) {
17
+ if (baseUrl === '/') {
18
+ return href.startsWith('/academy') || href.startsWith('/platform');
19
+ }
20
+
21
+ return href.startsWith(baseUrl);
22
+ }
23
+
19
24
  function A(props) {
20
- return <Link {...props} onClick={((e) => {
21
- e.preventDefault();
22
- window.location.assign(props.href || props.to);
23
- })}>
24
- {props.children}
25
- </Link>;
25
+ const { siteConfig } = useDocusaurusContext();
26
+ if (useLink(props.href, siteConfig.baseUrl)) {
27
+ return <Link {...props}>
28
+ {props.children}
29
+ </Link>;
30
+ }
31
+
32
+ return <a {...props}>{props.children}</a>;
26
33
  }
27
34
 
28
35
  function Hit({ hit, children }) {
29
- return <A to={hit.url}>{children}</A>;
36
+ return <A href={hit.url}>{children}</A>;
30
37
  }
31
38
 
32
39
  function ResultsFooter({ state, onClose }) {
33
40
  const { generateSearchPageLink } = useSearchPage();
34
41
  return (
35
- <A to={generateSearchPageLink(state.query)} onClick={onClose}>
42
+ <A href={generateSearchPageLink(state.query)} onClick={onClose}>
36
43
  <Translate
37
44
  id="theme.SearchBar.seeAll"
38
45
  values={{ count: state.context.nbHits }}>
@@ -49,7 +56,6 @@ function mergeFacetFilters(f1, f2) {
49
56
 
50
57
  function DocSearch({ contextualSearch, externalUrlRegex, ...props }) {
51
58
  const { siteMetadata, siteConfig } = useDocusaurusContext();
52
- const processSearchResultUrl = useSearchResultUrlProcessor();
53
59
  const contextualSearchFacetFilters = useAlgoliaContextualFacetFilters();
54
60
  const configFacetFilters = props.searchParameters?.facetFilters ?? [];
55
61
  const facetFilters = contextualSearch
@@ -120,15 +126,12 @@ function DocSearch({ contextualSearch, externalUrlRegex, ...props }) {
120
126
  window.location.href = itemUrl;
121
127
  },
122
128
  }).current;
123
- const transformItems = useRef((items) => (props.transformItems
124
- ? // Custom transformItems
125
- props.transformItems(items)
126
- : // Default transformItems
127
- items.map((item) => ({
128
- ...item,
129
- url: processSearchResultUrl(item.url).replace(new RegExp(`^${siteConfig.baseUrl}`), '/'),
130
- }))),
131
- ).current;
129
+ const transformItems = useRef((items) => (items.map((item) => {
130
+ if (item.url.startsWith(siteConfig.url)) {
131
+ return { ...item, url: item.url.substring(siteConfig.url.length) };
132
+ }
133
+ return item;
134
+ }))).current;
132
135
  const resultsFooterComponent = useMemo(
133
136
  () =>
134
137
  // eslint-disable-next-line react/no-unstable-nested-components,react/display-name,implicit-arrow-linebreak