diff --git a/gatsby-config.js b/gatsby-config.js
index 9ec38a1a..26cee8ca 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -44,16 +44,17 @@ module.exports = {
description: config.siteDescription,
siteUrl: config.siteUrl,
algolia: {
- appId: process.env.ALGOLIA_APP_ID,
- searchOnlyApiKey: process.env.ALGOLIA_SEARCH_ONLY_API_KEY,
- indexName: process.env.ALGOLIA_INDEX_NAME
+ appId: process.env.ALGOLIA_APP_ID || "none",
+ searchOnlyApiKey: process.env.ALGOLIA_SEARCH_ONLY_API_KEY || "none",
+ indexName: process.env.ALGOLIA_INDEX_NAME || "none",
+ available: !algoliaMissing
}
},
plugins: [
{
resolve: `gatsby-plugin-beam-analytics`,
options: {
- dataToken: process.env.BEAM_ID
+ dataToken: process.env.BEAM_ID || "none"
}
},
`gatsby-plugin-styled-jsx`, // the plugin's code is inserted directly to gatsby-node.js and gatsby-ssr.js files
diff --git a/plugins/gatsby-plugin-beam-analytics/gatsby-ssr.js b/plugins/gatsby-plugin-beam-analytics/gatsby-ssr.js
index 157ed726..9b760427 100644
--- a/plugins/gatsby-plugin-beam-analytics/gatsby-ssr.js
+++ b/plugins/gatsby-plugin-beam-analytics/gatsby-ssr.js
@@ -1,7 +1,11 @@
const React = require("react");
exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => {
- if (pluginOptions.dataToken && process.env.NODE_ENV === "production") {
+ if (
+ pluginOptions.dataToken &&
+ pluginOptions.dataToken !== "none" &&
+ process.env.NODE_ENV === "production"
+ ) {
setHeadComponents([
)}
diff --git a/src/components/Menu/Menu.js b/src/components/Menu/Menu.js
index 0f6b6ff8..e97bec76 100644
--- a/src/components/Menu/Menu.js
+++ b/src/components/Menu/Menu.js
@@ -30,10 +30,10 @@ class Menu extends React.Component {
{ to: "/type/podcast", label: "Podcasts", icon: icon("podcast") },
{ to: "/type/book", label: "Books", icon: icon("book") },
{ to: "/category/", label: "Topics", icon: Tag },
- { to: "/search/", label: "Search", icon: Search },
+ this.props.searchAvailable && { to: "/search/", label: "Search", icon: Search },
...pages,
{ to: "/contact/", label: "Contact", icon: Envelope }
- ];
+ ].filter(item => item); // Lazily filter out undefined items
this.renderedItems = []; // will contain references to rendered DOM elements of menu
}
diff --git a/src/components/Menu/Menu.test.js b/src/components/Menu/Menu.test.js
index 9fb5542c..5c9ebeb4 100644
--- a/src/components/Menu/Menu.test.js
+++ b/src/components/Menu/Menu.test.js
@@ -21,11 +21,12 @@ describe("Menu", () => {
fontLoaded={loaded}
pages={pages}
theme={theme}
+ searchAvailable={true}
/>
);
});
it("includes a search item", () => {
- expect(screen.getByText("Search")).toBeTruthy();
+ expect(screen.queryByText("Search")).toBeTruthy();
});
});
diff --git a/src/layouts/index.js b/src/layouts/index.js
index 6529a5c9..97884090 100644
--- a/src/layouts/index.js
+++ b/src/layouts/index.js
@@ -101,13 +101,25 @@ class Layout extends React.Component {
id
htmlAst
}
+ site {
+ siteMetadata {
+ algolia {
+ available
+ }
+ }
+ }
}
`}
render={data => {
const { children } = this.props;
const {
footnote: { htmlAst: footnoteHTMLAst, html: footnoteHTML },
- pages: { edges: pages }
+ pages: { edges: pages },
+ site: {
+ siteMetadata: {
+ algolia: { available: searchAvailable }
+ }
+ }
} = data;
return (
@@ -119,6 +131,7 @@ class Layout extends React.Component {
path={this.props.location.pathname}
pages={pages}
theme={this.state.theme}
+ searchAvailable={searchAvailable}
/>
{children}