diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-24 12:33:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-24 12:33:51 +0000 |
commit | 3ea39841c8049525e31e9f4d6300f0c60cdb42de (patch) | |
tree | 855de60a8872eafb5911acd303aedcdbfe713a73 /site/assets/js/search.js | |
parent | Inital commit. (diff) | |
download | bootstrap-html-3ea39841c8049525e31e9f4d6300f0c60cdb42de.tar.xz bootstrap-html-3ea39841c8049525e31e9f4d6300f0c60cdb42de.zip |
Adding upstream version 5.2.3+dfsg.upstream/5.2.3+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | site/assets/js/search.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/site/assets/js/search.js b/site/assets/js/search.js new file mode 100644 index 0000000..9bad274 --- /dev/null +++ b/site/assets/js/search.js @@ -0,0 +1,47 @@ +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT +// IT'S ALL JUST JUNK FOR OUR DOCS! +// ++++++++++++++++++++++++++++++++++++++++++ + +(() => { + 'use strict' + + const searchElement = document.getElementById('docsearch') + + if (!window.docsearch || !searchElement) { + return + } + + const siteDocsVersion = searchElement.getAttribute('data-bd-docs-version') + + window.docsearch({ + apiKey: '3151f502c7b9e9dafd5e6372b691a24e', + indexName: 'bootstrap', + appId: 'AK7KMZKZHQ', + container: searchElement, + searchParameters: { + facetFilters: [`version:${siteDocsVersion}`] + }, + transformItems(items) { + return items.map(item => { + const liveUrl = 'https://getbootstrap.com/' + + item.url = window.location.origin.startsWith(liveUrl) ? + // On production, return the result as is + item.url : + // On development or Netlify, replace `item.url` with a trailing slash, + // so that the result link is relative to the server root + item.url.replace(liveUrl, '/') + + // Prevent jumping to first header + if (item.anchor === 'content') { + item.url = item.url.replace(/#content$/, '') + item.anchor = null + } + + return item + }) + }, + // Set debug to `true` if you want to inspect the dropdown + debug: false + }) +})() |