mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
WIP
Signed-off-by: DanRoscigno <dan@roscigno.com>
This commit is contained in:
parent
fa5a30c52c
commit
c16ae38a8b
1 changed files with 53 additions and 0 deletions
|
@ -36,12 +36,65 @@ title: Page name
|
||||||
```
|
```
|
||||||
## Configure the Algolia index
|
## Configure the Algolia index
|
||||||
|
|
||||||
|
Each Algolia index has several configuration options. The section to configure for page boosting is **Index** → **Configuration** → **Relevance Essentials** → **Ranking and Sorting** → **Custom Ranking**
|
||||||
|
|
||||||
|
If **`weight.pageRank`** is not in the list of custom ranking attributes, add it with **Add custom ranking attribute**.
|
||||||
|
|
||||||
## Configure the Algolia Crawler
|
## Configure the Algolia Crawler
|
||||||
|
|
||||||
|
The Algolia Crawler configuration is edited in your Algolia account. Access the crawler editor from the Algolia dashboard for your Algolia application at **Data sources** → **Crawler** by choosing the name of the crawler, and then **Editor**.
|
||||||
|
|
||||||
|
There are three edits to be made:
|
||||||
|
|
||||||
|
### Modify the `recordExtractor` function
|
||||||
|
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
In the JavaScript snippets the `$` is the Cheerio instance, and allows you to manipulate the `DOM`. Links are in the **More information** section at the end of this doc.
|
||||||
|
:::
|
||||||
|
|
||||||
|
The `recordExtractor` needs access to the Cheerio instance to extract the metadata from the `DOM`.
|
||||||
|
|
||||||
|
Verify that the `recordExtractor` function includes the Cheerio instance as a parameter. Your record extractor function may have the `$`, if so you can skip this step. Your record extractor may also have other parameters listed, you should not remove parameters.
|
||||||
|
|
||||||
|
```js
|
||||||
|
recordExtractor: ({ $, helpers }) => {
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extract the `pageBoost` metadata
|
||||||
|
|
||||||
|
Within the `recordExtractor` function add the highlighted line to extract the `pageBoost` metadata into `const pageBoost`, with a default value of 0 if no metadata is present in the page.
|
||||||
|
|
||||||
|
```js
|
||||||
|
recordExtractor: ({ $, helpers }) => {
|
||||||
|
// highlight-start
|
||||||
|
// Extract metadata
|
||||||
|
const pageBoost = $("meta[name='pageBoost']").attr("content") || "0";
|
||||||
|
// highlight-end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Assign the `pageRank`
|
||||||
|
|
||||||
|
```js
|
||||||
|
foo
|
||||||
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## More information
|
## More information
|
||||||
|
|
||||||
[Adding metadata](../guides/markdown-features/markdown-features-head-metadata.mdx)
|
[Adding metadata](../guides/markdown-features/markdown-features-head-metadata.mdx)
|
||||||
|
|
||||||
Configuring [Search](../search.mdx)
|
Configuring [Search](../search.mdx)
|
||||||
|
|
||||||
|
Algolia Crawler [record extractor](https://docsearch.algolia.com/docs/record-extractor)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue