Skip to content

Commit 4aa0c2c

Browse files
authored
fix: updating the templates page (#2273)
* fix: updating the templates page The templates page needs some work. The first thing I saw is that it alluded to being able to create a crawler. As a docsearch user, this is confusing. We automatically create a crawler for the user, additional crawlers get confusing for the user. Provide additional information about updating templates, as we're talking about templates here. Verify the current templates, I see the default one isn't quite right. Given that we use the same template for Docusaurus v2 and v3 combine those. Add the Starlight template. * Combined Docusaurus v2 and v3 templates Its confusing to have two separate sections that are exactly the same * added astro starlight template * remove pkgdown and add starlight pkgdown no longer references Algolia added starlight as an integration partner
1 parent cdfa993 commit 4aa0c2c

2 files changed

Lines changed: 52 additions & 45 deletions

File tree

packages/website/docs/integrations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ So, if you're using one of the following tools, checkout their documentation to
1212
- [Docusaurus v2 & v3][3] - [Using Algolia DocSearch][4]
1313
- [VuePress][5] - [Algolia Search][6]
1414
- [VitePress][21] - [Search][22]
15-
- [pkgdown][7] - [DocSearch indexing][8]
15+
- [Starlight][7] - [Algolia Search][8]
1616
- [LaRecipe][9] - [Algolia Search][10]
1717
- [Orchid][11] - [Algolia Search][12]
1818
- [Smooth DOC][13] - [DocSearch][14]
@@ -28,8 +28,8 @@ If you're maintaining a similar tool and want us to add you to the list, [feel f
2828
[4]: https://docusaurus.io/docs/search#using-algolia-docsearch
2929
[5]: https://vuepress.vuejs.org/
3030
[6]: https://vuepress.vuejs.org/theme/default-theme-config.html#algolia-search
31-
[7]: https://pkgdown.r-lib.org/
32-
[8]: https://pkgdown.r-lib.org/articles/search.html#bootstrap-3-algolia
31+
[7]: https://starlight.astro.build/
32+
[8]: https://starlight.astro.build/guides/site-search/#algolia-docsearch
3333
[9]: https://larecipe.saleem.dev/docs/2.2/overview
3434
[10]: https://larecipe.saleem.dev/docs/2.2/search#available-engines
3535
[11]: https://orchid.run

packages/website/docs/templates.mdx

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
---
2-
title: Config templates
2+
title: Config Templates
33
---
44

55
import useBaseUrl from '@docusaurus/useBaseUrl';
66

7-
To help you create the best search experience for your users, we provide config templates for multiple websites generators. If you'd like to add a new template to our list, or believe we should update an existing one, please [send us an email][1] or [open a pull request][2].
7+
To help you create the best search experience for your users, we provide out-of-the-box crawler config templates for multiple websites generators. If you'd like to add a new template to our list, or believe we should update an existing one, please [let us know on Discord][1] or [open a pull request][2].
88

9-
> If you want to better understand the default parameters of the configs below, you can take a look at the [Crawler documentation](https://www.algolia.com/doc/tools/crawler/apis/configuration/).
9+
> If you want to better understand the default parameters of the configs below, take a look at the [Crawler documentation](https://www.algolia.com/doc/tools/crawler/apis/configuration/).
1010
11-
## From the Crawler UI
11+
## Getting Started
1212

13-
Templates are available when you [create a new Crawler](https://crawler.algolia.com/admin/crawlers/create). They will automatically be filled with your website URL, Algolia credentials and index name.
13+
Once approved for DocSearch, we will automatically create a Crawler on your behalf, include your URL, and the Algolia creditials for your appId, apiKey, and indexName. If we detected that you are using any of the predefined generators, we'll attempt to automatically assign the proper template that matches your generator. However, this is not gauranteed. If no specific generator is detected, we will apply the default template seen below.
1414

15-
<div className="uil-ta-center">
16-
<img
17-
src={useBaseUrl('img/assets/new-crawler-creation.png')}
18-
alt="Algolia Crawler creation page"
19-
/>
20-
</div>
15+
## Updating the Template
16+
17+
You can manually update the crawler template by going to dashboard.algolia.com, click "Data sources", select your crawler, and go to the editor page. From there you can edit the Javascript directly. Note that you can make draft changes without saving, test the changes using the "URL Tester", and then "Save" once you're happy with your changes.
2118

22-
## Default template
19+
## Default Template
2320

2421
<details><summary>default.js</summary>
2522
<div>
@@ -119,7 +116,7 @@ new Crawler({
119116
</div>
120117
</details>
121118

122-
## Docusaurus v1 template
119+
## Docusaurus v1 Template
123120

124121
<details><summary>docusaurus-v1.js</summary>
125122
<div>
@@ -275,7 +272,7 @@ new Crawler({
275272
</div>
276273
</details>
277274

278-
## Docusaurus v2 template
275+
## Docusaurus v2 & v3 Template
279276

280277
<details><summary>docusaurus-v2.js</summary>
281278
<div>
@@ -389,9 +386,9 @@ new Crawler({
389386
</div>
390387
</details>
391388

392-
## Docusaurus v3 template
389+
## Astro Starlight Template
393390

394-
<details><summary>docusaurus-v3.js</summary>
391+
<details><summary>starlight.js</summary>
395392
<div>
396393

397394
```js
@@ -409,31 +406,47 @@ new Crawler({
409406
indexName: 'YOUR_INDEX_NAME',
410407
pathsToMatch: ['https://YOUR_WEBSITE_URL/**'],
411408
recordExtractor: ({ $, helpers }) => {
412-
// priority order: deepest active sub list header -> navbar active item -> 'Documentation'
409+
// Get the top level menu item
413410
const lvl0 =
414-
$(
415-
'.menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active'
416-
)
417-
.last()
418-
.text() || 'Documentation';
411+
$('details:has(a[aria-current="page"])')
412+
.find("summary")
413+
.find("span")
414+
.text() || "Documentation";
415+
416+
// Get the second level menu item
417+
var lvl1 = 'a[aria-current="page"] span';
418+
var lvl2 = "main h1";
419+
var lvl3 = "main h2";
420+
var lvl4 = "main h3";
421+
var lvl5 = "main h4";
422+
var lvl6 = "main h5";
423+
424+
// If not able to get the menu item then make this generic
425+
if (lvl0 === "Documentation") {
426+
lvl1 = "main h1";
427+
lvl2 = "main h2";
428+
lvl3 = "main h3";
429+
lvl4 = "main h4";
430+
lvl5 = "main h5";
431+
lvl6 = "main h6";
432+
}
419433

420434
return helpers.docsearch({
421435
recordProps: {
422436
lvl0: {
423-
selectors: '',
437+
selectors: "",
424438
defaultValue: lvl0,
425439
},
426-
lvl1: ['header h1', 'article h1'],
427-
lvl2: 'article h2',
428-
lvl3: 'article h3',
429-
lvl4: 'article h4',
430-
lvl5: 'article h5, article td:first-child',
431-
lvl6: 'article h6',
432-
content: 'article p, article li, article td:last-child',
440+
lvl1: lvl1,
441+
lvl2: lvl2,
442+
lvl3: lvl3,
443+
lvl4: lvl4,
444+
lvl5: lvl5,
445+
lvl6: lvl6,
446+
content: "main p, main li",
433447
},
434448
indexHeadings: true,
435449
aggregateContent: true,
436-
recordVersion: 'v3',
437450
});
438451
},
439452
},
@@ -443,17 +456,12 @@ new Crawler({
443456
attributesForFaceting: [
444457
'type',
445458
'lang',
446-
'language',
447-
'version',
448-
'docusaurus_tag',
449459
],
450460
attributesToRetrieve: [
451461
'hierarchy',
452462
'content',
453463
'anchor',
454464
'url',
455-
'url_without_anchor',
456-
'type',
457465
],
458466
attributesToHighlight: ['hierarchy', 'content'],
459467
attributesToSnippet: ['content:10'],
@@ -494,7 +502,6 @@ new Crawler({
494502
advancedSyntax: true,
495503
attributeCriteriaComputedByMinProximity: true,
496504
removeWordsIfNoResults: 'allOptional',
497-
separatorsToIndex: '_',
498505
},
499506
},
500507
});
@@ -503,7 +510,7 @@ new Crawler({
503510
</div>
504511
</details>
505512

506-
## Vuepress v1 template
513+
## Vuepress v1 Template
507514

508515
<details><summary>vuepress-v1.js</summary>
509516
<div>
@@ -614,7 +621,7 @@ new Crawler({
614621
</div>
615622
</details>
616623

617-
## Vuepress v2 template
624+
## Vuepress v2 Template
618625

619626
<details><summary>vuepress-v2.js</summary>
620627
<div>
@@ -705,7 +712,7 @@ new Crawler({
705712
</div>
706713
</details>
707714

708-
## Vitepress template
715+
## Vitepress Template
709716

710717
<details><summary>vitepress.js</summary>
711718
<div>
@@ -795,7 +802,7 @@ new Crawler({
795802
</div>
796803
</details>
797804

798-
## pkgdown template
805+
## pkgdown Template
799806

800807
<details><summary>pkgdown.js</summary>
801808
<div>
@@ -958,5 +965,5 @@ new Crawler({
958965
</div>
959966
</details>
960967

961-
[1]: mailto:docsearch@algolia.com
968+
[1]: https://alg.li/discord
962969
[2]: https://github.com/algolia/docsearch

0 commit comments

Comments
 (0)