@seqera/docusaurus-theme-seqera 1.0.29-next.97 → 1.0.30-next.101

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": "@seqera/docusaurus-theme-seqera",
3
- "version": "1.0.29-next.97",
3
+ "version": "1.0.30-next.101",
4
4
  "description": "Seqera docs theme for Docusaurus",
5
5
  "author": "Seqera docs team <education@seqera.io>",
6
6
  "license": "Apache-2.0",
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * Swizzled from docusaurus-theme-search-typesense SearchBar.
8
- * Adds full hierarchy breadcrumbs to the path shown under each modal result.
9
- */
10
- export default function SearchBar(): JSX.Element;
@@ -1,210 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * Swizzled from docusaurus-theme-search-typesense SearchBar.
8
- * Adds full hierarchy breadcrumbs to the path shown under each modal result.
9
- */
10
- import React, {useState, useRef, useCallback, useMemo} from 'react';
11
- // @ts-ignore
12
- import {createPortal} from 'react-dom';
13
- // @ts-ignore
14
- import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
15
- // @ts-ignore
16
- import {useHistory} from '@docusaurus/router';
17
- // @ts-ignore
18
- import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
19
- // @ts-ignore
20
- import Link from '@docusaurus/Link';
21
- // @ts-ignore
22
- import {isRegexpStringMatch} from '@docusaurus/theme-common';
23
- import {
24
- DocSearchButton,
25
- useDocSearchKeyboardEvents,
26
- } from 'typesense-docsearch-react';
27
- import {useTypesenseContextualFilters} from 'docusaurus-theme-search-typesense/client';
28
- // @ts-ignore
29
- import Translate from '@docusaurus/Translate';
30
- // @ts-ignore
31
- import translations from '@theme/SearchTranslations';
32
- import {DocsPreferredVersionContextProvider} from '@docusaurus/plugin-content-docs/lib/client/index.js';
33
- let DocSearchModal = null;
34
- function Hit({hit, children}) {
35
- return <Link to={hit.url}>{children}</Link>;
36
- }
37
- function ResultsFooter({state, onClose}) {
38
- const {
39
- siteConfig: {baseUrl},
40
- } = useDocusaurusContext();
41
- return (
42
- <Link
43
- to={`${baseUrl}search?q=${encodeURIComponent(state.query)}`}
44
- onClick={onClose}>
45
- <Translate
46
- id="theme.SearchBar.seeAll"
47
- values={{count: state.context.nbHits}}>
48
- {'See all {count} results'}
49
- </Translate>
50
- </Link>
51
- );
52
- }
53
- /**
54
- * Build a breadcrumb string from all ancestor hierarchy levels of a hit.
55
- * For lvl2+ and content hits this replaces the single-level hierarchy.lvl1
56
- * path with the full parent chain (e.g. "Nextflow › Getting Started › Installation").
57
- */
58
- function buildBreadcrumb(item) {
59
- const {type} = item;
60
- const maxLevel =
61
- type === 'content' ? 7 : parseInt(type.replace('lvl', ''), 10);
62
- const parts = [];
63
- for (let i = 0; i < maxLevel; i++) {
64
- const val = item[`hierarchy.lvl${i}`];
65
- if (val) parts.push(val);
66
- }
67
- return parts.length > 1 ? parts.join(' › ') : null;
68
- }
69
- function DocSearch({contextualSearch, externalUrlRegex, ...props}) {
70
- const contextualSearchFacetFilters = useTypesenseContextualFilters();
71
- const configFacetFilters = props.typesenseSearchParameters?.filter_by ?? '';
72
- const facetFilters = contextualSearch
73
- ? [contextualSearchFacetFilters, configFacetFilters]
74
- .filter((e) => e)
75
- .join(' && ')
76
- : configFacetFilters;
77
- const typesenseSearchParameters = {
78
- filter_by: facetFilters,
79
- ...props.typesenseSearchParameters,
80
- };
81
- const {withBaseUrl} = useBaseUrlUtils();
82
- const history = useHistory();
83
- const searchContainer = useRef(null);
84
- const searchButtonRef = useRef(null);
85
- const [isOpen, setIsOpen] = useState(false);
86
- const [initialQuery, setInitialQuery] = useState(undefined);
87
- const importDocSearchModalIfNeeded = useCallback(() => {
88
- if (DocSearchModal) {
89
- return Promise.resolve();
90
- }
91
- return Promise.all([
92
- // @ts-ignore
93
- import('typesense-docsearch-react/modal'),
94
- // @ts-ignore
95
- import('typesense-docsearch-react/style'),
96
- // @ts-ignore
97
- import('./styles.css'),
98
- ]).then(([{DocSearchModal: Modal}]) => {
99
- DocSearchModal = Modal;
100
- });
101
- }, []);
102
- const onOpen = useCallback(() => {
103
- importDocSearchModalIfNeeded().then(() => {
104
- searchContainer.current = document.createElement('div');
105
- document.body.insertBefore(
106
- searchContainer.current,
107
- document.body.firstChild,
108
- );
109
- setIsOpen(true);
110
- });
111
- }, [importDocSearchModalIfNeeded]);
112
- const onClose = useCallback(() => {
113
- setIsOpen(false);
114
- searchContainer.current?.remove();
115
- }, []);
116
- const onInput = useCallback(
117
- (event) => {
118
- importDocSearchModalIfNeeded().then(() => {
119
- setIsOpen(true);
120
- setInitialQuery(event.key);
121
- });
122
- },
123
- [importDocSearchModalIfNeeded],
124
- );
125
- const navigator = useRef({
126
- navigate({itemUrl}) {
127
- if (isRegexpStringMatch(externalUrlRegex, itemUrl)) {
128
- window.location.href = itemUrl;
129
- } else {
130
- history.push(itemUrl);
131
- }
132
- },
133
- }).current;
134
- const transformItems = useRef((items) =>
135
- items.map((item) => {
136
- // Transform absolute URL to relative.
137
- const withRelativeUrl = isRegexpStringMatch(externalUrlRegex, item.url)
138
- ? item
139
- : {
140
- ...item,
141
- url: withBaseUrl(
142
- `${new URL(item.url).pathname}${new URL(item.url).hash}`,
143
- ),
144
- };
145
- // Overwrite hierarchy.lvl1 with the full ancestor breadcrumb so the
146
- // DocSearch-Hit-path slot shows the complete path for lvl2+ results.
147
- const breadcrumb = buildBreadcrumb(withRelativeUrl);
148
- if (!breadcrumb) return withRelativeUrl;
149
- return {
150
- ...withRelativeUrl,
151
- 'hierarchy.lvl1': breadcrumb,
152
- };
153
- }),
154
- ).current;
155
- const resultsFooterComponent = useMemo(
156
- () =>
157
- // eslint-disable-next-line react/no-unstable-nested-components
158
- (footerProps) =>
159
- <ResultsFooter {...footerProps} onClose={onClose} />,
160
- [onClose],
161
- );
162
- useDocSearchKeyboardEvents({
163
- isOpen,
164
- onOpen,
165
- onClose,
166
- onInput,
167
- searchButtonRef,
168
- });
169
- return (
170
- <>
171
- <DocSearchButton
172
- onTouchStart={importDocSearchModalIfNeeded}
173
- onFocus={importDocSearchModalIfNeeded}
174
- onMouseOver={importDocSearchModalIfNeeded}
175
- onClick={onOpen}
176
- ref={searchButtonRef}
177
- translations={translations.button}
178
- />
179
- {isOpen &&
180
- DocSearchModal &&
181
- searchContainer.current &&
182
- createPortal(
183
- <DocSearchModal
184
- onClose={onClose}
185
- initialScrollY={window.scrollY}
186
- initialQuery={initialQuery}
187
- navigator={navigator}
188
- transformItems={transformItems}
189
- hitComponent={Hit}
190
- {...(props.searchPagePath && {resultsFooterComponent})}
191
- {...props}
192
- typesenseSearchParameters={typesenseSearchParameters}
193
- typesenseServerConfig={props.typesenseServerConfig}
194
- typesenseCollectionName={props.typesenseCollectionName}
195
- placeholder={translations.placeholder}
196
- translations={translations.modal}
197
- />,
198
- searchContainer.current,
199
- )}
200
- </>
201
- );
202
- }
203
- export default function SearchBar() {
204
- const {siteConfig} = useDocusaurusContext();
205
- return (
206
- <DocsPreferredVersionContextProvider>
207
- <DocSearch {...siteConfig.themeConfig.typesense} />
208
- </DocsPreferredVersionContextProvider>
209
- );
210
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- :root {
9
- --docsearch-primary-color: var(--ifm-color-primary);
10
- --docsearch-text-color: var(--ifm-font-color-base);
11
- }
12
-
13
- .DocSearch-Button {
14
- margin: 0;
15
- transition: all var(--ifm-transition-fast)
16
- var(--ifm-transition-timing-default);
17
- }
18
-
19
- .DocSearch-Container {
20
- z-index: calc(var(--ifm-z-index-fixed) + 1);
21
- }
@@ -1,280 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * Swizzled from docusaurus-theme-search-typesense SearchBar.
8
- * Adds full hierarchy breadcrumbs to the path shown under each modal result.
9
- */
10
-
11
- import React, {useState, useRef, useCallback, useMemo} from 'react';
12
- // @ts-ignore
13
- import {createPortal} from 'react-dom';
14
- // @ts-ignore
15
- import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
16
- // @ts-ignore
17
- import {useHistory} from '@docusaurus/router';
18
- // @ts-ignore
19
- import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
20
- // @ts-ignore
21
- import Link from '@docusaurus/Link';
22
- // @ts-ignore
23
- import {isRegexpStringMatch} from '@docusaurus/theme-common';
24
- import {
25
- DocSearchButton,
26
- useDocSearchKeyboardEvents,
27
- } from 'typesense-docsearch-react';
28
- import {useTypesenseContextualFilters} from 'docusaurus-theme-search-typesense/client';
29
- // @ts-ignore
30
- import Translate from '@docusaurus/Translate';
31
- // @ts-ignore
32
- import translations from '@theme/SearchTranslations';
33
- import {DocsPreferredVersionContextProvider} from '@docusaurus/plugin-content-docs/lib/client/index.js';
34
-
35
- import type {
36
- DocSearchModal as DocSearchModalType,
37
- DocSearchModalProps,
38
- } from 'typesense-docsearch-react';
39
- import type {
40
- InternalDocSearchHit,
41
- StoredDocSearchHit,
42
- } from 'typesense-docsearch-react/dist/esm/types';
43
-
44
- type DocSearchProps = Omit<
45
- DocSearchModalProps,
46
- 'onClose' | 'initialScrollY'
47
- > & {
48
- contextualSearch?: string;
49
- externalUrlRegex?: string;
50
- searchPagePath: boolean | string;
51
- };
52
-
53
- let DocSearchModal: typeof DocSearchModalType | null = null;
54
-
55
- function Hit({
56
- hit,
57
- children,
58
- }: {
59
- hit: InternalDocSearchHit | StoredDocSearchHit;
60
- children: React.ReactNode;
61
- }) {
62
- return <Link to={hit.url}>{children}</Link>;
63
- }
64
-
65
- type ResultsFooterProps = {
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
- state: any;
68
- onClose: () => void;
69
- };
70
-
71
- function ResultsFooter({state, onClose}: ResultsFooterProps) {
72
- const {
73
- siteConfig: {baseUrl},
74
- } = useDocusaurusContext();
75
-
76
- return (
77
- <Link
78
- to={`${baseUrl}search?q=${encodeURIComponent(state.query)}`}
79
- onClick={onClose}>
80
- <Translate
81
- id="theme.SearchBar.seeAll"
82
- values={{count: state.context.nbHits}}>
83
- {'See all {count} results'}
84
- </Translate>
85
- </Link>
86
- );
87
- }
88
-
89
- /**
90
- * Build a breadcrumb string from all ancestor hierarchy levels of a hit.
91
- * For lvl2+ and content hits this replaces the single-level hierarchy.lvl1
92
- * path with the full parent chain (e.g. "Nextflow › Getting Started › Installation").
93
- */
94
- function buildBreadcrumb(
95
- item: InternalDocSearchHit | StoredDocSearchHit,
96
- ): string | null {
97
- const {type} = item;
98
- const maxLevel =
99
- type === 'content' ? 7 : parseInt(type.replace('lvl', ''), 10);
100
-
101
- const parts: string[] = [];
102
- for (let i = 0; i < maxLevel; i++) {
103
- const val = (item as unknown as Record<string, string | null>)[
104
- `hierarchy.lvl${i}`
105
- ];
106
- if (val) parts.push(val);
107
- }
108
-
109
- return parts.length > 1 ? parts.join(' › ') : null;
110
- }
111
-
112
- function DocSearch({
113
- contextualSearch,
114
- externalUrlRegex,
115
- ...props
116
- }: DocSearchProps) {
117
- const contextualSearchFacetFilters =
118
- useTypesenseContextualFilters() as string;
119
- const configFacetFilters: string =
120
- props.typesenseSearchParameters?.filter_by ?? '';
121
- const facetFilters = contextualSearch
122
- ? [contextualSearchFacetFilters, configFacetFilters]
123
- .filter((e) => e)
124
- .join(' && ')
125
- : configFacetFilters;
126
-
127
- const typesenseSearchParameters = {
128
- filter_by: facetFilters,
129
- ...props.typesenseSearchParameters,
130
- };
131
-
132
- const {withBaseUrl} = useBaseUrlUtils();
133
- const history = useHistory();
134
- const searchContainer = useRef<HTMLDivElement | null>(null);
135
- const searchButtonRef = useRef<HTMLButtonElement>(null);
136
- const [isOpen, setIsOpen] = useState(false);
137
- const [initialQuery, setInitialQuery] = useState<string | undefined>(
138
- undefined,
139
- );
140
-
141
- const importDocSearchModalIfNeeded = useCallback(() => {
142
- if (DocSearchModal) {
143
- return Promise.resolve();
144
- }
145
- return Promise.all([
146
- // @ts-ignore
147
- import('typesense-docsearch-react/modal') as Promise<
148
- typeof import('typesense-docsearch-react')
149
- >,
150
- // @ts-ignore
151
- import('typesense-docsearch-react/style'),
152
- // @ts-ignore
153
- import('./styles.css'),
154
- ]).then(([{DocSearchModal: Modal}]) => {
155
- DocSearchModal = Modal;
156
- });
157
- }, []);
158
-
159
- const onOpen = useCallback(() => {
160
- importDocSearchModalIfNeeded().then(() => {
161
- searchContainer.current = document.createElement('div');
162
- document.body.insertBefore(
163
- searchContainer.current,
164
- document.body.firstChild,
165
- );
166
- setIsOpen(true);
167
- });
168
- }, [importDocSearchModalIfNeeded]);
169
-
170
- const onClose = useCallback(() => {
171
- setIsOpen(false);
172
- searchContainer.current?.remove();
173
- }, []);
174
-
175
- const onInput = useCallback(
176
- (event: KeyboardEvent) => {
177
- importDocSearchModalIfNeeded().then(() => {
178
- setIsOpen(true);
179
- setInitialQuery(event.key);
180
- });
181
- },
182
- [importDocSearchModalIfNeeded],
183
- );
184
-
185
- const navigator = useRef({
186
- navigate({itemUrl}: {itemUrl?: string}) {
187
- if (isRegexpStringMatch(externalUrlRegex, itemUrl)) {
188
- window.location.href = itemUrl!;
189
- } else {
190
- history.push(itemUrl!);
191
- }
192
- },
193
- }).current;
194
-
195
- const transformItems = useRef<DocSearchModalProps['transformItems']>(
196
- (items) =>
197
- items.map((item) => {
198
- // Transform absolute URL to relative.
199
- const withRelativeUrl = isRegexpStringMatch(externalUrlRegex, item.url)
200
- ? item
201
- : {
202
- ...item,
203
- url: withBaseUrl(
204
- `${new URL(item.url).pathname}${new URL(item.url).hash}`,
205
- ),
206
- };
207
-
208
- // Overwrite hierarchy.lvl1 with the full ancestor breadcrumb so the
209
- // DocSearch-Hit-path slot shows the complete path for lvl2+ results.
210
- const breadcrumb = buildBreadcrumb(withRelativeUrl);
211
- if (!breadcrumb) return withRelativeUrl;
212
-
213
- return {
214
- ...withRelativeUrl,
215
- 'hierarchy.lvl1': breadcrumb,
216
- };
217
- }),
218
- ).current;
219
-
220
- const resultsFooterComponent: DocSearchProps['resultsFooterComponent'] =
221
- useMemo(
222
- () =>
223
- // eslint-disable-next-line react/no-unstable-nested-components
224
- (footerProps: Omit<ResultsFooterProps, 'onClose'>): JSX.Element => (
225
- <ResultsFooter {...footerProps} onClose={onClose} />
226
- ),
227
- [onClose],
228
- );
229
-
230
- useDocSearchKeyboardEvents({
231
- isOpen,
232
- onOpen,
233
- onClose,
234
- onInput,
235
- searchButtonRef,
236
- });
237
-
238
- return (
239
- <>
240
- <DocSearchButton
241
- onTouchStart={importDocSearchModalIfNeeded}
242
- onFocus={importDocSearchModalIfNeeded}
243
- onMouseOver={importDocSearchModalIfNeeded}
244
- onClick={onOpen}
245
- ref={searchButtonRef}
246
- translations={translations.button}
247
- />
248
- {isOpen &&
249
- DocSearchModal &&
250
- searchContainer.current &&
251
- createPortal(
252
- <DocSearchModal
253
- onClose={onClose}
254
- initialScrollY={window.scrollY}
255
- initialQuery={initialQuery}
256
- navigator={navigator}
257
- transformItems={transformItems}
258
- hitComponent={Hit}
259
- {...(props.searchPagePath && {resultsFooterComponent})}
260
- {...props}
261
- typesenseSearchParameters={typesenseSearchParameters}
262
- typesenseServerConfig={props.typesenseServerConfig}
263
- typesenseCollectionName={props.typesenseCollectionName}
264
- placeholder={translations.placeholder}
265
- translations={translations.modal}
266
- />,
267
- searchContainer.current,
268
- )}
269
- </>
270
- );
271
- }
272
-
273
- export default function SearchBar(): JSX.Element {
274
- const {siteConfig} = useDocusaurusContext();
275
- return (
276
- <DocsPreferredVersionContextProvider>
277
- <DocSearch {...(siteConfig.themeConfig.typesense as DocSearchProps)} />
278
- </DocsPreferredVersionContextProvider>
279
- );
280
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- :root {
9
- --docsearch-primary-color: var(--ifm-color-primary);
10
- --docsearch-text-color: var(--ifm-font-color-base);
11
- }
12
-
13
- .DocSearch-Button {
14
- margin: 0;
15
- transition: all var(--ifm-transition-fast)
16
- var(--ifm-transition-timing-default);
17
- }
18
-
19
- .DocSearch-Container {
20
- z-index: calc(var(--ifm-z-index-fixed) + 1);
21
- }