From 07bbb80a24197f1cd8ce1a263370d4797bf4a9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= <20689156+shortcuts@users.noreply.github.com> Date: Mon, 22 Nov 2021 17:46:50 +0100 Subject: [PATCH] docs(template): update Docusaurus v2 template (#1184) --- packages/website/docs/templates.mdx | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/website/docs/templates.mdx b/packages/website/docs/templates.mdx index fa45d0aa..1331cadb 100644 --- a/packages/website/docs/templates.mdx +++ b/packages/website/docs/templates.mdx @@ -28,7 +28,6 @@ Templates are available when you [create a new Crawler](https://crawler.algolia.
docusaurus-v1.js
- ```js new Crawler({ appId: 'YOUR_APP_ID', @@ -177,13 +176,11 @@ new Crawler({
- ## Docusaurus v2 template
docusaurus-v2.js
- ```js new Crawler({ appId: 'YOUR_APP_ID', @@ -198,14 +195,19 @@ new Crawler({ indexName: 'YOUR_INDEX_NAME', pathsToMatch: ['https://YOUR_WEBSITE_URL/**'], recordExtractor: ({ $, helpers }) => { + // priority order: deepest active sub list header -> navbar active item -> 'Documentation' + const lvl0 = + $( + '.menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active' + ) + .last() + .text() || 'Documentation'; + return helpers.docsearch({ recordProps: { lvl0: { - selectors: [ - '.menu__link.menu__link--sublist.menu__link--active', - '.navbar__item.navbar__link--active', - ], - defaultValue: 'Documentation', + selectors: '', + defaultValue: lvl0, }, lvl1: 'header h1', lvl2: 'article h2', @@ -306,13 +308,11 @@ new Crawler({
- ## Vuepress v1 template
vuepress-v1.js
- ```js new Crawler({ appId: 'YOUR_APP_ID', @@ -417,13 +417,11 @@ new Crawler({
- ## Vuepress v2 template
vuepress-v2.js
- ```js new Crawler({ appId: 'YOUR_APP_ID', @@ -528,13 +526,11 @@ new Crawler({
- ## Vitepress template
vitepress.js
- ```js new Crawler({ appId: 'YOUR_APP_ID', @@ -638,13 +634,11 @@ new Crawler({
- ## pkgdown template
pkgdown.js
- ```js new Crawler({ appId: 'YOUR_APP_ID', @@ -820,6 +814,5 @@ new Crawler({
- [1]: mailto:docsearch@algolia.com [2]: https://github.com/algolia/docsearch