DocSearch
Doks comes with FlexSearch preconfigured out of the box. If you want to use DocSearch in stead, this guide will explain how.
Set up DocSearch
To follow this guide, you’ll need an existing Doks site and a DocSearch project.
If a file does not exist in your projects’ root, copy the file over from node_modules/@thulite/doks-core/
. Make sure to use the same directory structure in your root.
Add parameters
Add the following parameters to config/_default/params.toml
:
Install dependencies
DocSearch provides a UI component, bundled as JavaScript and CSS packages. You’ll need both of these packages to display the widget:
This will install the required dependencies.
Add buttons
Add to layouts/partials/header/header.html
buttons for mobile and desktop to trigger the DocSearch modal.
Button mobile
Add (around line 38) after <!-- FlexSearch mobile -->
:
Button mobile
Button desktop
Add (around line 170) after <!-- FlexSearch desktop -->
:
Button desktop
Add script
Create script
Add the following to assets/js/docsearch.js
and update with your appId
, indexName
, and apiKey
:
Load script
Add to layouts/partials/footer/script-footer-custom.html
:
Add styles
Create variables
Add to assets/scss/common/_variables-docsearch.scss
and (optionally) override:
Variables DocSearch
Update styles
Add to assets/scss/common/_custom.scss
:
Custom styles
Load styles
Add (around line 98) to assets/scss/app.scss
after // 9. Custom styles
:
Update PurgeCSS
In config/postcss.config.js
update dynamicAttributes
and ...whitelister
: