From a70bb879fb0a2d51ab9687590a1608defb9866fb Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 13 Apr 2023 16:54:23 +1200 Subject: [PATCH] ENH Use the new algolia search index and API --- .env.development | 5 +- README.md | 6 +- gatsby-browser.js | 1 - gatsby-ssr.js | 4 +- package.json | 1 + purgecss.config.js | 4 +- src/components/Header.tsx | 21 +-- src/components/Layout.tsx | 23 ++-- src/components/SearchBox.tsx | 102 ++++++--------- src/components/Sidebar.tsx | 8 +- src/theme/assets/scss/ss-docs.scss | 49 +------ src/theme/assets/scss/ss-variables.scss | 1 + src/theme/assets/scss/theme/_docs.scss | 41 +----- src/theme/assets/scss/theme/_search.scss | 17 +++ src/theme/assets/scss/theme/styles.scss | 4 +- src/theme/assets/search/algolia.css | 2 - yarn.lock | 158 +++++++++++++++++++++++ 17 files changed, 250 insertions(+), 197 deletions(-) create mode 100644 src/theme/assets/scss/theme/_search.scss delete mode 100644 src/theme/assets/search/algolia.css diff --git a/.env.development b/.env.development index 16ea983..748ef6f 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,4 @@ -GATSBY_DOCSEARCH_API_KEY=0ca39e6ea6a622b335fc0c71482aff54 -GATSBY_DOCSEARCH_INDEX=silverstripe +GATSBY_DOCSEARCH_API_KEY=771f028079eed8878a64f1dfcadc5914 +GATSBY_DOCSEARCH_INDEX=silverstripedocs +GATSBY_DOCSEARCH_APP_ID=2VQS6HLO6K DOCS_CONTEXT=docs \ No newline at end of file diff --git a/README.md b/README.md index 7cdfb0a..31f767c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ When **creating a new major branch for a pre-release major version** - Add the new major to `sources-docs.js` and `sources-user.js` - Add the new major to the version select in `src/components/Header.tsx` - Add the major to the `PRE_RELEASE` array in the `getVersionMessage` function in `src/utils/nodes.ts` +- Add the new major version to the [algolia crawler script](https://crawler.algolia.com/admin/crawlers/3d14ccdd-f9ae-4957-bc0a-5b21b4c29af3/configuration/edit) For **new stable releases**, you will need to do the following @@ -80,10 +81,13 @@ Then, run the build. ``` yarn build-docs yarn serve + +# or with docker +./docker/run build && ./docker/run serve -p 8000 ``` These commands will give you an exact representation of how the site will run on a production server, with -statically generated html files and server-side rendering. +statically generated html files, css purging, and server-side rendering. ## Toggling between docs and userhelp diff --git a/gatsby-browser.js b/gatsby-browser.js index e3937fa..481c23e 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1,7 +1,6 @@ require("prismjs/themes/prism-okaidia.css"); require("./src/theme/assets/scss/theme.scss"); require('./src/theme/assets/fontawesome/css/all.css'); -require('./src/theme/assets/search/algolia.css'); const React = require('react'); const Layout = require('./src/components/Layout').default; diff --git a/gatsby-ssr.js b/gatsby-ssr.js index 9cd58e3..d773eea 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -1,7 +1,6 @@ const React = require('react'); const Layout = require('./src/components/Layout').default; const NodeProvider = require('./src/components/NodeProvider').default; -const { setCurrentPath } = require('./src/utils/nodes'); /** * Applies the node provider (static query of all documents) @@ -19,7 +18,7 @@ exports.wrapPageElement = ({ element, props }) => { exports.onRenderBody = ({ setPostBodyComponents, setHeadComponents, pathname }) => { // Rules that cannot be touched by purgecss because they come in from client side rendering - setHeadComponents([ + setHeadComponents([