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