mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-10 22:24:19 +01:00
6b49d26b21
* Migrate to DocSearch v3 Fixes #33338 * initialize `siteDocsVersion` const after the proper check * Update site/layouts/partials/stylesheet.html Co-authored-by: GeoSot <geo.sotis@gmail.com> * Update header.html * code review changes * Update search.js * Fix contrast issue, tweak some styles * Fix some navbar changes * temporary safari fix for docsearch3 Co-authored-by: GeoSot <geo.sotis@gmail.com> Co-authored-by: XhmikosR <xhmikosr@gmail.com>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
// 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
|
|
})
|
|
})()
|