From 39183e6dc89e5e9dec80999c7eec728f724caa9e Mon Sep 17 00:00:00 2001 From: Steven Hicks Date: Fri, 21 Feb 2020 14:12:24 -0600 Subject: [PATCH] Rough implementation of algolia-based search box --- packages/palette-docs/gatsby-config.js | 11 +++++++++++ packages/palette-docs/gatsby-ssr.js | 17 +++++++++++++++++ packages/palette-docs/package.json | 1 + .../src/components/Sidebar/SearchBox.tsx | 15 +++++++++++++++ .../src/components/Sidebar/index.tsx | 2 ++ yarn.lock | 7 +++++++ 6 files changed, 53 insertions(+) create mode 100644 packages/palette-docs/src/components/Sidebar/SearchBox.tsx diff --git a/packages/palette-docs/gatsby-config.js b/packages/palette-docs/gatsby-config.js index 378e33a54..4025c482b 100644 --- a/packages/palette-docs/gatsby-config.js +++ b/packages/palette-docs/gatsby-config.js @@ -77,5 +77,16 @@ module.exports = { "gatsby-plugin-styled-components", "gatsby-plugin-typescript", "gatsby-plugin-sitemap", + { + // Currently this plugin is only being used to hook up the script & css, so the options don't matter a whole lot. + // We could probably just implement the few bits that work for our scenario instead. + resolve: `gatsby-plugin-algolia-docsearch`, //require.resolve("./gatsby-algolia-search.js"), + options: { + apiKey: "it-doesnt-matter-not-using-it", // required + indexName: "it-doesnt-matter-not-using-it", // required + inputSelector: ".it-doesnt-matter-not-using-it", // required + debug: true, // (bool)Optional. Default `false` + }, + }, ], } diff --git a/packages/palette-docs/gatsby-ssr.js b/packages/palette-docs/gatsby-ssr.js index 331d84fbd..781100420 100644 --- a/packages/palette-docs/gatsby-ssr.js +++ b/packages/palette-docs/gatsby-ssr.js @@ -1,4 +1,5 @@ // @ts-check +import React from "react" /** * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. @@ -8,3 +9,19 @@ import { Boot } from "./src/Boot" export const wrapRootElement = Boot + +export function onRenderBody( + { setHeadComponents, setPostBodyComponents }, + { apiKey, indexName, inputSelector, debug = false } +) { + setPostBodyComponents([ +