hotfix: fix version decorator on search results

fix-write
Scott Anderson 2023-09-13 10:47:35 -06:00
parent 9cf8aa4803
commit 9db6fcda90
1 changed files with 4 additions and 3 deletions

View File

@ -9,6 +9,7 @@
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script> <script>
var multiVersion = ['influxdb']
docsearch({ docsearch({
apiKey: '501434b53a46a92a7931aecc7c9672e2', apiKey: '501434b53a46a92a7931aecc7c9672e2',
appId: 'WHM9UWMP6M', appId: 'WHM9UWMP6M',
@ -17,7 +18,7 @@ docsearch({
// Set debug to true if you want to inspect the dropdown // Set debug to true if you want to inspect the dropdown
debug: true, debug: true,
transformData: function (hits) { transformData: function (hits) {
function fmtVersion (version) { function fmtVersion (version, productKey) {
if (version == null) { if (version == null) {
return ''; return '';
} else if (version === 'cloud') { } else if (version === 'cloud') {
@ -28,7 +29,7 @@ docsearch({
return 'Cloud Dedicated'; return 'Cloud Dedicated';
} else if (version === 'clustered') { } else if (version === 'clustered') {
return 'Clustered'; return 'Clustered';
} else if (/v\d+/.test(version)) { } else if (multiVersion.includes(productKey)) {
return version; return version;
} else { } else {
return ''; return '';
@ -47,7 +48,7 @@ docsearch({
hits.map(hit => { hits.map(hit => {
pathData = new URL(hit.url).pathname.split('/').filter(n => n); pathData = new URL(hit.url).pathname.split('/').filter(n => n);
product = productNames[pathData[0]]; product = productNames[pathData[0]];
version = fmtVersion(pathData[1]); version = fmtVersion(pathData[1], pathData[0]);
hit.product = product; hit.product = product;
hit.version = version; hit.version = version;