mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
Allow for extra algoliaOptions for search
This commit is contained in:
parent
5c3f74ddcc
commit
de2897f108
1 changed files with 28 additions and 25 deletions
|
@ -8,40 +8,25 @@
|
|||
*/
|
||||
|
||||
const React = require("react");
|
||||
const fs = require("fs");
|
||||
const HeaderNav = require("./nav/HeaderNav.js");
|
||||
const Head = require("./Head.js");
|
||||
const Footer = require(process.cwd() + "/core/Footer.js");
|
||||
const translation = require("../server/translation.js");
|
||||
|
||||
const CWD = process.cwd();
|
||||
|
||||
class Site extends React.Component {
|
||||
/*
|
||||
goes in body after navPusher
|
||||
|
||||
<div id="fb-root" />
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"
|
||||
/>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-44373548-17', 'auto');
|
||||
ga('send', 'pageview');
|
||||
|
||||
|
||||
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)
|
||||
){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";
|
||||
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
|
||||
|
||||
docsearch({
|
||||
apiKey: '833906d7486e4059359fa58823c4ef56',
|
||||
indexName: 'jest',
|
||||
inputSelector: '#search_input_react'
|
||||
});
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
|
@ -62,7 +47,10 @@ class Site extends React.Component {
|
|||
this.props.config.url +
|
||||
this.props.config.baseUrl +
|
||||
(this.props.url || "index.html");
|
||||
|
||||
let latestVersion;
|
||||
if (fs.existsSync(CWD + "/versions.json")) {
|
||||
latestVersion = require(CWD + "/versions.json")[0];
|
||||
}
|
||||
return (
|
||||
<html>
|
||||
<Head
|
||||
|
@ -104,17 +92,32 @@ class Site extends React.Component {
|
|||
}}
|
||||
/>}
|
||||
{this.props.config.algolia &&
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
(this.props.config.algolia.algoliaOptions
|
||||
? <script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
var search = docsearch({
|
||||
apiKey: '${this.props.config.algolia.apiKey}',
|
||||
indexName: '${this.props.config.algolia.indexName}',
|
||||
inputSelector: '#search_input_react',
|
||||
algoliaOptions: '${this.props.config.algolia.algoliaOptions
|
||||
.replace("VERSION", this.props.version || latestVersion)
|
||||
.replace("LANGUAGE", this.props.language)}'
|
||||
});
|
||||
`
|
||||
}}
|
||||
/>
|
||||
: <script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
var search = docsearch({
|
||||
apiKey: '${this.props.config.algolia.apiKey}',
|
||||
indexName: '${this.props.config.algolia.indexName}',
|
||||
inputSelector: '#search_input_react'
|
||||
});
|
||||
`
|
||||
}}
|
||||
/>}
|
||||
}}
|
||||
/>)}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue