Skip to content

Commit

Permalink
[SPARK-33479][DOC] Make the API Key of DocSearch configurable
Browse files Browse the repository at this point in the history
### 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 #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 #30292 (comment), 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>
  • Loading branch information
gengliangwang authored and maropu committed Nov 19, 2020
1 parent 56a8510 commit 4267ca9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 12 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
8 changes: 1 addition & 7 deletions docs/_layouts/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,7 @@ <h1 class="title">{{ page.title }}</h1>
// 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 -->
Expand Down

0 comments on commit 4267ca9

Please sign in to comment.