@docusaurus/theme-search-algolia 3.7.0-canary-6291 → 3.7.0-canary-6293
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/lib/theme/SearchPage/index.js +23 -20
- package/package.json +10 -10
- package/src/theme/SearchPage/index.tsx +25 -22
|
@@ -15,11 +15,11 @@ import Link from '@docusaurus/Link';
|
|
|
15
15
|
import {useAllDocsData} from '@docusaurus/plugin-content-docs/client';
|
|
16
16
|
import {
|
|
17
17
|
HtmlClassNameProvider,
|
|
18
|
+
PageMetadata,
|
|
18
19
|
useEvent,
|
|
19
20
|
usePluralForm,
|
|
20
21
|
useSearchQueryString,
|
|
21
22
|
} from '@docusaurus/theme-common';
|
|
22
|
-
import {useTitleFormatter} from '@docusaurus/theme-common/internal';
|
|
23
23
|
import Translate, {translate} from '@docusaurus/Translate';
|
|
24
24
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
25
25
|
import {
|
|
@@ -114,6 +114,24 @@ function SearchVersionSelectList({docsSearchVersionsHelpers}) {
|
|
|
114
114
|
</div>
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
+
function getSearchPageTitle(searchQuery) {
|
|
118
|
+
return searchQuery
|
|
119
|
+
? translate(
|
|
120
|
+
{
|
|
121
|
+
id: 'theme.SearchPage.existingResultsTitle',
|
|
122
|
+
message: 'Search results for "{query}"',
|
|
123
|
+
description: 'The search page title for non-empty query',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
query: searchQuery,
|
|
127
|
+
},
|
|
128
|
+
)
|
|
129
|
+
: translate({
|
|
130
|
+
id: 'theme.SearchPage.emptyResultsTitle',
|
|
131
|
+
message: 'Search the documentation',
|
|
132
|
+
description: 'The search page title for empty query',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
117
135
|
function SearchPageContent() {
|
|
118
136
|
const {
|
|
119
137
|
i18n: {currentLocale},
|
|
@@ -125,6 +143,7 @@ function SearchPageContent() {
|
|
|
125
143
|
const documentsFoundPlural = useDocumentsFoundPlural();
|
|
126
144
|
const docsSearchVersionsHelpers = useDocsSearchVersionsHelpers();
|
|
127
145
|
const [searchQuery, setSearchQuery] = useSearchQueryString();
|
|
146
|
+
const pageTitle = getSearchPageTitle(searchQuery);
|
|
128
147
|
const initialSearchResultState = {
|
|
129
148
|
items: [],
|
|
130
149
|
query: null,
|
|
@@ -246,23 +265,6 @@ function SearchPageContent() {
|
|
|
246
265
|
{threshold: 1},
|
|
247
266
|
),
|
|
248
267
|
);
|
|
249
|
-
const getTitle = () =>
|
|
250
|
-
searchQuery
|
|
251
|
-
? translate(
|
|
252
|
-
{
|
|
253
|
-
id: 'theme.SearchPage.existingResultsTitle',
|
|
254
|
-
message: 'Search results for "{query}"',
|
|
255
|
-
description: 'The search page title for non-empty query',
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
query: searchQuery,
|
|
259
|
-
},
|
|
260
|
-
)
|
|
261
|
-
: translate({
|
|
262
|
-
id: 'theme.SearchPage.emptyResultsTitle',
|
|
263
|
-
message: 'Search the documentation',
|
|
264
|
-
description: 'The search page title for empty query',
|
|
265
|
-
});
|
|
266
268
|
const makeSearch = useEvent((page = 0) => {
|
|
267
269
|
if (contextualSearch) {
|
|
268
270
|
algoliaHelper.addDisjunctiveFacetRefinement('docusaurus_tag', 'default');
|
|
@@ -306,8 +308,9 @@ function SearchPageContent() {
|
|
|
306
308
|
}, [makeSearch, searchResultState.lastPage]);
|
|
307
309
|
return (
|
|
308
310
|
<Layout>
|
|
311
|
+
<PageMetadata title={pageTitle} />
|
|
312
|
+
|
|
309
313
|
<Head>
|
|
310
|
-
<title>{useTitleFormatter(getTitle())}</title>
|
|
311
314
|
{/*
|
|
312
315
|
We should not index search pages
|
|
313
316
|
See https://github.com/facebook/docusaurus/pull/3233
|
|
@@ -316,7 +319,7 @@ function SearchPageContent() {
|
|
|
316
319
|
</Head>
|
|
317
320
|
|
|
318
321
|
<div className="container margin-vert--lg">
|
|
319
|
-
<Heading as="h1">{
|
|
322
|
+
<Heading as="h1">{pageTitle}</Heading>
|
|
320
323
|
|
|
321
324
|
<form className="row" onSubmit={(e) => e.preventDefault()}>
|
|
322
325
|
<div
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-search-algolia",
|
|
3
|
-
"version": "3.7.0-canary-
|
|
3
|
+
"version": "3.7.0-canary-6293",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": [
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@docsearch/react": "^3.9.0",
|
|
37
|
-
"@docusaurus/core": "3.7.0-canary-
|
|
38
|
-
"@docusaurus/logger": "3.7.0-canary-
|
|
39
|
-
"@docusaurus/plugin-content-docs": "3.7.0-canary-
|
|
40
|
-
"@docusaurus/theme-common": "3.7.0-canary-
|
|
41
|
-
"@docusaurus/theme-translations": "3.7.0-canary-
|
|
42
|
-
"@docusaurus/utils": "3.7.0-canary-
|
|
43
|
-
"@docusaurus/utils-validation": "3.7.0-canary-
|
|
37
|
+
"@docusaurus/core": "3.7.0-canary-6293",
|
|
38
|
+
"@docusaurus/logger": "3.7.0-canary-6293",
|
|
39
|
+
"@docusaurus/plugin-content-docs": "3.7.0-canary-6293",
|
|
40
|
+
"@docusaurus/theme-common": "3.7.0-canary-6293",
|
|
41
|
+
"@docusaurus/theme-translations": "3.7.0-canary-6293",
|
|
42
|
+
"@docusaurus/utils": "3.7.0-canary-6293",
|
|
43
|
+
"@docusaurus/utils-validation": "3.7.0-canary-6293",
|
|
44
44
|
"algoliasearch": "^5.17.1",
|
|
45
45
|
"algoliasearch-helper": "^3.22.6",
|
|
46
46
|
"clsx": "^2.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"utility-types": "^3.10.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@docusaurus/module-type-aliases": "3.7.0-canary-
|
|
54
|
+
"@docusaurus/module-type-aliases": "3.7.0-canary-6293"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=18.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "0081f71eac22598acc91c2bb91d42933a950a324"
|
|
64
64
|
}
|
|
@@ -25,11 +25,11 @@ import Link from '@docusaurus/Link';
|
|
|
25
25
|
import {useAllDocsData} from '@docusaurus/plugin-content-docs/client';
|
|
26
26
|
import {
|
|
27
27
|
HtmlClassNameProvider,
|
|
28
|
+
PageMetadata,
|
|
28
29
|
useEvent,
|
|
29
30
|
usePluralForm,
|
|
30
31
|
useSearchQueryString,
|
|
31
32
|
} from '@docusaurus/theme-common';
|
|
32
|
-
import {useTitleFormatter} from '@docusaurus/theme-common/internal';
|
|
33
33
|
import Translate, {translate} from '@docusaurus/Translate';
|
|
34
34
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
35
35
|
import {
|
|
@@ -160,6 +160,25 @@ type ResultDispatcher =
|
|
|
160
160
|
| {type: 'update'; value: ResultDispatcherState}
|
|
161
161
|
| {type: 'advance'; value?: undefined};
|
|
162
162
|
|
|
163
|
+
function getSearchPageTitle(searchQuery: string | undefined): string {
|
|
164
|
+
return searchQuery
|
|
165
|
+
? translate(
|
|
166
|
+
{
|
|
167
|
+
id: 'theme.SearchPage.existingResultsTitle',
|
|
168
|
+
message: 'Search results for "{query}"',
|
|
169
|
+
description: 'The search page title for non-empty query',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
query: searchQuery,
|
|
173
|
+
},
|
|
174
|
+
)
|
|
175
|
+
: translate({
|
|
176
|
+
id: 'theme.SearchPage.emptyResultsTitle',
|
|
177
|
+
message: 'Search the documentation',
|
|
178
|
+
description: 'The search page title for empty query',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
163
182
|
function SearchPageContent(): ReactNode {
|
|
164
183
|
const {
|
|
165
184
|
i18n: {currentLocale},
|
|
@@ -167,12 +186,13 @@ function SearchPageContent(): ReactNode {
|
|
|
167
186
|
const {
|
|
168
187
|
algolia: {appId, apiKey, indexName, contextualSearch},
|
|
169
188
|
} = useAlgoliaThemeConfig();
|
|
170
|
-
|
|
171
189
|
const processSearchResultUrl = useSearchResultUrlProcessor();
|
|
172
190
|
const documentsFoundPlural = useDocumentsFoundPlural();
|
|
173
191
|
|
|
174
192
|
const docsSearchVersionsHelpers = useDocsSearchVersionsHelpers();
|
|
175
193
|
const [searchQuery, setSearchQuery] = useSearchQueryString();
|
|
194
|
+
const pageTitle = getSearchPageTitle(searchQuery);
|
|
195
|
+
|
|
176
196
|
const initialSearchResultState: ResultDispatcherState = {
|
|
177
197
|
items: [],
|
|
178
198
|
query: null,
|
|
@@ -310,24 +330,6 @@ function SearchPageContent(): ReactNode {
|
|
|
310
330
|
),
|
|
311
331
|
);
|
|
312
332
|
|
|
313
|
-
const getTitle = () =>
|
|
314
|
-
searchQuery
|
|
315
|
-
? translate(
|
|
316
|
-
{
|
|
317
|
-
id: 'theme.SearchPage.existingResultsTitle',
|
|
318
|
-
message: 'Search results for "{query}"',
|
|
319
|
-
description: 'The search page title for non-empty query',
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
query: searchQuery,
|
|
323
|
-
},
|
|
324
|
-
)
|
|
325
|
-
: translate({
|
|
326
|
-
id: 'theme.SearchPage.emptyResultsTitle',
|
|
327
|
-
message: 'Search the documentation',
|
|
328
|
-
description: 'The search page title for empty query',
|
|
329
|
-
});
|
|
330
|
-
|
|
331
333
|
const makeSearch = useEvent((page: number = 0) => {
|
|
332
334
|
if (contextualSearch) {
|
|
333
335
|
algoliaHelper.addDisjunctiveFacetRefinement('docusaurus_tag', 'default');
|
|
@@ -380,8 +382,9 @@ function SearchPageContent(): ReactNode {
|
|
|
380
382
|
|
|
381
383
|
return (
|
|
382
384
|
<Layout>
|
|
385
|
+
<PageMetadata title={pageTitle} />
|
|
386
|
+
|
|
383
387
|
<Head>
|
|
384
|
-
<title>{useTitleFormatter(getTitle())}</title>
|
|
385
388
|
{/*
|
|
386
389
|
We should not index search pages
|
|
387
390
|
See https://github.com/facebook/docusaurus/pull/3233
|
|
@@ -390,7 +393,7 @@ function SearchPageContent(): ReactNode {
|
|
|
390
393
|
</Head>
|
|
391
394
|
|
|
392
395
|
<div className="container margin-vert--lg">
|
|
393
|
-
<Heading as="h1">{
|
|
396
|
+
<Heading as="h1">{pageTitle}</Heading>
|
|
394
397
|
|
|
395
398
|
<form className="row" onSubmit={(e) => e.preventDefault()}>
|
|
396
399
|
<div
|