..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 | // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
// IT'S ALL JUST JUNK FOR OUR DOCS!
// ++++++++++++++++++++++++++++++++++++++++++
/*!
* JavaScript for Bootstrap's docs (https://getbootstrap.com/)
* Copyright 2024 The Bootstrap Authors
* Licensed under the Creative Commons Attribution 3.0 Unported License.
* For details, see https://creativecommons.org/licenses/by/3.0/.
*/
import docsearch from '@docsearch/js'
// https://gohugo.io/hugo-pipes/js/#options
// eslint-disable-next-line import/no-unresolved
import { appId, apiKey, indexName } from '@params';
(() => {
const searchElement = document.getElementById('docsearch')
if (!searchElement) {
return
}
const siteDocsVersion = searchElement.getAttribute('data-bd-docs-version')
docsearch({
apiKey,
indexName,
appId,
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
})
}
})
})()
|
|