[SPARK-33479][DOC] Make the API Key of DocSearch configurable

### What changes were proposed in this pull request?

Make the API key of DocSearch configurable and avoid hardcoding in the HTML template

### Why are the changes needed?

After https://github.com/apache/spark/pull/30292, our Spark documentation site supports searching.
However, the default API key always points to the latest release doc. We have to set different API keys for different releases. Otherwise, the search results are always based on the latest documentation(https://spark.apache.org/docs/latest/) even when visiting the documentation of previous releases.

As per discussion in https://github.com/apache/spark/pull/30292#issuecomment-725613417, we should make the API key configurable and set different values for different releases.

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Manual test

Closes #30409 from gengliangwang/apiKey.

Authored-by: Gengliang Wang <gengliang.wang@databricks.com>
Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
This commit is contained in:
Gengliang Wang 2020-11-19 11:20:18 +09:00 committed by Takeshi Yamamuro
parent 56a8510e19
commit 4267ca98fa
2 changed files with 13 additions and 7 deletions

View file

@ -26,3 +26,15 @@ SCALA_VERSION: "2.12.10"
MESOS_VERSION: 1.0.0
SPARK_ISSUE_TRACKER_URL: https://issues.apache.org/jira/browse/SPARK
SPARK_GITHUB_URL: https://github.com/apache/spark
# Before a new release, we should apply a new `apiKey` for the new Spark documentation
# on https://docsearch.algolia.com/. Otherwise, after release, the search results are always based
# on the latest documentation(https://spark.apache.org/docs/latest/) even when visiting the
# documentation of previous releases.
DOCSEARCH_SCRIPT: |
docsearch({
apiKey: 'b18ca3732c502995563043aa17bc6ecb',
indexName: 'apache_spark',
inputSelector: '#docsearch-input',
enhancedSearchInput: true,
debug: false // Set debug to true if you want to inspect the dropdown
});

View file

@ -187,13 +187,7 @@
// 2. a JavaScript snippet to be inserted in your website that will bind this Algolia index
// to your search input and display its results in a dropdown UI. If you want to find more
// details on how works DocSearch, check the docs of DocSearch.
docsearch({
apiKey: 'b18ca3732c502995563043aa17bc6ecb',
indexName: 'apache_spark',
inputSelector: '#docsearch-input',
enhancedSearchInput: true,
debug: false // Set debug to true if you want to inspect the dropdown
});
{{site.DOCSEARCH_SCRIPT}}
</script>
<!-- MathJax Section -->