diff --git a/gatsby-config.js b/gatsby-config.js index df920391b17..b3accf3e5e6 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -11,6 +11,9 @@ module.exports = { resolve: 'gatsby-theme-carbon', options: { mdxExtensions: ['.mdx'], + isSearchEnabled: true, + iconPath: './src/images/favicon-32.png', + titleType: 'append', repository: { baseUrl: 'https://github.com/carbon-design-system/carbon-www', subDirectory: '', diff --git a/package.json b/package.json index 8f80ff2ad69..c76b2479e25 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "classnames": "^2.2.6", "gatsby": "^2.13.41", "gatsby-plugin-compile-es6-packages": "^2.1.0", - "gatsby-theme-carbon": "^1.7.0", + "gatsby-theme-carbon": "^1.7.1", "html-loader": "^0.5.5", "lodash": "^4.17.15", "markdown-it": "^9.0.1", diff --git a/src/images/favicon-32.png b/src/images/favicon-32.png new file mode 100644 index 00000000000..ac3455b9de5 Binary files /dev/null and b/src/images/favicon-32.png differ diff --git a/src/util/hooks/useSearch.js b/src/util/hooks/useSearch.js new file mode 100644 index 00000000000..772ed0ad6ff --- /dev/null +++ b/src/util/hooks/useSearch.js @@ -0,0 +1,22 @@ +import { useEffect } from 'react'; + +const useAlgoliaSearch = () => { + useEffect(() => { + if ( + typeof window === `undefined` || + typeof window.docsearch === `undefined` + ) { + console.warn(`Search has failed to load and now is being disabled`); + } else { + window.docsearch({ + apiKey: `296ea0c1d0e96b2b04900d0f4d1a6329`, + indexName: `carbondesignsystem`, + inputSelector: `#doc-search`, + // set this to true if you need to debug css + debug: true, + }); + } + }); +}; + +export default useAlgoliaSearch; diff --git a/yarn.lock b/yarn.lock index ae8267f87b0..fd13524a227 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6417,10 +6417,10 @@ gatsby-telemetry@^1.1.11: stack-utils "1.0.2" uuid "3.3.2" -gatsby-theme-carbon@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/gatsby-theme-carbon/-/gatsby-theme-carbon-1.7.0.tgz#707db04ae3f69c73937a130b2cc5fc060de89561" - integrity sha512-S/T1SK0tlF0WmG4g8JKsyzvD1B83oBslFwUtklwA/oCU9SJbtlthZYWUtYU+mf27Vgi9tq4qpx3iTUfZzbUTvQ== +gatsby-theme-carbon@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/gatsby-theme-carbon/-/gatsby-theme-carbon-1.7.1.tgz#e1f9bbef1257475d628dbe8c2b03c1935ada07a5" + integrity sha512-4ZVUjQMlkaXqkiDAXku4dlYj+5d9g6lUtS3n/w1x4N00aWVGyuqOGF8PM7WtRmbtLpLM7rDDdSzI4ALLWTOC8A== dependencies: "@carbon/addons-website" "0.0.1-alpha.21" "@carbon/elements" "^10.4.0"