From 14dfcff769af624f0f1534740d811ab315532992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Wed, 4 Oct 2017 19:13:30 -0700 Subject: [PATCH] Support algoliaOptions object as value in siteConfig.js (#113) --- docs/guides-search.md | 5 ++++- lib/core/Site.js | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/guides-search.md b/docs/guides-search.md index 2038438d15..e7c6d64055 100644 --- a/docs/guides-search.md +++ b/docs/guides-search.md @@ -29,7 +29,10 @@ const siteConfig = { ... algolia: { ... - algoliaOptions: '{ facetFilters: [ "tags:VERSION" ], hitsPerPage: 5 }' + algoliaOptions: { + facetFilters: [ "tags:VERSION" ], + hitsPerPage: 5 + } }, } ``` diff --git a/lib/core/Site.js b/lib/core/Site.js index 4424f717b4..e68d6ca954 100644 --- a/lib/core/Site.js +++ b/lib/core/Site.js @@ -99,9 +99,11 @@ class Site extends React.Component { apiKey: '${this.props.config.algolia.apiKey}', indexName: '${this.props.config.algolia.indexName}', inputSelector: '#search_input_react', - algoliaOptions: '${this.props.config.algolia.algoliaOptions + algoliaOptions: ${ + JSON.stringify(this.props.config.algolia.algoliaOptions) .replace("VERSION", this.props.version || latestVersion) - .replace("LANGUAGE", this.props.language)}' + .replace("LANGUAGE", this.props.language) + } }); ` }}