-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
COM-140 search #61
Open
thomasm0
wants to merge
18
commits into
develop
Choose a base branch
from
feature/com-140-search
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
COM-140 search #61
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
86cf718
desktop nav search button
thomasm0 8fc2fd6
mobile search button added
thomasm0 7a0dc84
wip - functional search buttons on desktop and mobile
thomasm0 699dc1f
fixed mobile menu button and button positioning
thomasm0 2c18802
working algolia search config
thomasm0 ae0feb0
search config documentation
thomasm0 edc588a
font-family fix for nav search button
thomasm0 19a9cf4
change search page input to use design-system input
thomasm0 313fa0c
vitest setup with basic test
thomasm0 404a97a
lint fixes
thomasm0 4c184f3
working header test
thomasm0 37bec6c
docs for vitest config
thomasm0 7853acc
delete old unused pages
thomasm0 11e5211
remove commented code
thomasm0 141629a
github action for lint and test
thomasm0 f81efab
link to search docs added to readme and text correction
thomasm0 e87235c
cleanup test dir
thomasm0 d895afa
comments cleanup
thomasm0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Lint and test | ||
|
||
on: | ||
push: | ||
branches-ignore: [main] | ||
|
||
jobs: | ||
setup: | ||
name: Setup and install | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
- name: Lint scripts | ||
run: npm run lint | ||
- name: Test application | ||
run: npm run test run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Search | ||
|
||
This application uses Algolia for the search, as it is the [official Docusaurus search plugin](https://docusaurus.io/docs/search#using-algolia-docsearch) and provides a quick and easy search solution. | ||
|
||
## Config | ||
|
||
To implement this you need an Algolia Application. You can complete [this form](https://docsearch.algolia.com/apply/) and they will configure everything for you. Otherwise via the [Algolia dashboard](https://dashboard.algolia.com/), you need to create an Application. | ||
|
||
When creating an application manually, you need to link a `Crawler` to index the relevant content. Via the `Connectors` page you can link a `Crawler`. This comes with various config options, which can be seen when editing crawlers under the `Setup / Editor` page. | ||
|
||
The default Docusaurus v2 & v3 config should follow this template: | ||
|
||
```js | ||
new Crawler({ | ||
appId: 'YOUR_APP_ID', | ||
apiKey: 'YOUR_API_KEY', | ||
rateLimit: 8, | ||
maxDepth: 10, | ||
startUrls: ['https://YOUR_WEBSITE_URL/'], | ||
sitemaps: ['https://YOUR_WEBSITE_URL/sitemap.xml'], | ||
ignoreCanonicalTo: true, | ||
discoveryPatterns: ['https://YOUR_WEBSITE_URL/**'], | ||
actions: [ | ||
{ | ||
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: '', | ||
defaultValue: lvl0, | ||
}, | ||
lvl1: ['header h1', 'article h1'], | ||
lvl2: 'article h2', | ||
lvl3: 'article h3', | ||
lvl4: 'article h4', | ||
lvl5: 'article h5, article td:first-child', | ||
lvl6: 'article h6', | ||
content: 'article p, article li, article td:last-child', | ||
}, | ||
indexHeadings: true, | ||
aggregateContent: true, | ||
recordVersion: 'v3', | ||
}); | ||
}, | ||
}, | ||
], | ||
initialIndexSettings: { | ||
YOUR_INDEX_NAME: { | ||
attributesForFaceting: [ | ||
'type', | ||
'lang', | ||
'language', | ||
'version', | ||
'docusaurus_tag', | ||
], | ||
attributesToRetrieve: [ | ||
'hierarchy', | ||
'content', | ||
'anchor', | ||
'url', | ||
'url_without_anchor', | ||
'type', | ||
], | ||
attributesToHighlight: ['hierarchy', 'content'], | ||
attributesToSnippet: ['content:10'], | ||
camelCaseAttributes: ['hierarchy', 'content'], | ||
searchableAttributes: [ | ||
'unordered(hierarchy.lvl0)', | ||
'unordered(hierarchy.lvl1)', | ||
'unordered(hierarchy.lvl2)', | ||
'unordered(hierarchy.lvl3)', | ||
'unordered(hierarchy.lvl4)', | ||
'unordered(hierarchy.lvl5)', | ||
'unordered(hierarchy.lvl6)', | ||
'content', | ||
], | ||
distinct: true, | ||
attributeForDistinct: 'url', | ||
customRanking: [ | ||
'desc(weight.pageRank)', | ||
'desc(weight.level)', | ||
'asc(weight.position)', | ||
], | ||
ranking: [ | ||
'words', | ||
'filters', | ||
'typo', | ||
'attribute', | ||
'proximity', | ||
'exact', | ||
'custom', | ||
], | ||
highlightPreTag: '<span class="algolia-docsearch-suggestion--highlight">', | ||
highlightPostTag: '</span>', | ||
minWordSizefor1Typo: 3, | ||
minWordSizefor2Typos: 7, | ||
allowTyposOnNumericTokens: false, | ||
minProximity: 1, | ||
ignorePlurals: true, | ||
advancedSyntax: true, | ||
attributeCriteriaComputedByMinProximity: true, | ||
removeWordsIfNoResults: 'allOptional', | ||
separatorsToIndex: '_', | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
A lot of these simpler options can also be configured through the `Setup / Configuration` page. | ||
|
||
**Note the return from `recordExtractor` in line 42 has been edited, changing `lvl1: ['header h1', 'article h1'],` to `lvl1: ['article h1'],` otherwise the indexer will also index the word `Developers` from the global header title.** | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between ** and Note