This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 081b44d4d6 feat(WebSite) :DocSearch Filter By Version (#9134)
081b44d4d6 is described below
commit 081b44d4d630b643e483954e2499f59231ae0e37
Author: CritasWang <[email protected]>
AuthorDate: Thu Feb 23 22:58:20 2023 +0800
feat(WebSite) :DocSearch Filter By Version (#9134)
---
.../theme/components/AlgoliaSearchBox.vue | 26 +++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/site/src/main/.vuepress/theme/components/AlgoliaSearchBox.vue
b/site/src/main/.vuepress/theme/components/AlgoliaSearchBox.vue
index 0975b0130f..26fd990a35 100644
--- a/site/src/main/.vuepress/theme/components/AlgoliaSearchBox.vue
+++ b/site/src/main/.vuepress/theme/components/AlgoliaSearchBox.vue
@@ -31,8 +31,11 @@
<script>
export default {
props: ['options'],
-
+ data: () => ({
+ docVersion: 'master',
+ }),
mounted() {
+ this.docVersion = this.getBranch('master', this.$page.relativePath);
this.initialize(this.options, this.$lang);
},
@@ -49,7 +52,7 @@ export default {
...userOptions,
inputSelector: '#algolia-search-input',
// #697 Make docsearch work well at i18n mode.
- algoliaOptions: { facetFilters:
[`lang:${lang}`].concat(algoliaOptions.facetFilters || []), ...algoliaOptions },
+ algoliaOptions: { facetFilters: [`lang:${lang}`,
`version:${this.docVersion}`].concat(algoliaOptions.facetFilters || []),
...algoliaOptions },
});
});
},
@@ -58,7 +61,17 @@ export default {
this.$el.innerHTML = '<input id="algolia-search-input"
class="search-query">';
this.initialize(options, lang);
},
-
+ getBranch(branch = 'master', path = '') {
+ if (path.indexOf('UserGuide/Master') > -1 || path.indexOf('UserGuide')
=== -1) {
+ return branch;
+ }
+ const branchRex = /UserGuide\/V(\d+\.\d+\.x)/;
+ if (branchRex.test(path)) {
+ const tag = branchRex.exec(path)[1];
+ return `rel/${tag.replace('.x', '')}`;
+ }
+ return branch;
+ },
},
watch: {
@@ -66,6 +79,13 @@ export default {
this.update(this.options, newValue);
},
+ $page(newValue) {
+ const newVersion = this.getBranch('master', newValue.relativePath);
+ if (newVersion !== this.docVersion) {
+ this.docVersion = newVersion;
+ this.update(this.options, this.$lang);
+ }
+ },
options(newValue) {
this.update(newValue, this.$lang);
},