aboutsummaryrefslogtreecommitdiff
path: root/site/docs
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2018-10-19 19:43:12 +0300
committerXhmikosR <[email protected]>2018-10-19 22:09:50 +0300
commit282b77ee9c9fd382d5ed576ad5bf7a41d97ca2a5 (patch)
treefd93600d67e9eb7c04b68a035963fc45a2b41971 /site/docs
parenta16ffc7ba1035d41a2cb3e68df5b8c6f756f90b1 (diff)
downloadbootstrap-282b77ee9c9fd382d5ed576ad5bf7a41d97ca2a5.tar.xz
bootstrap-282b77ee9c9fd382d5ed576ad5bf7a41d97ca2a5.zip
docs search: take into account the current URL.
Diffstat (limited to 'site/docs')
-rw-r--r--site/docs/4.1/assets/js/src/search.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/site/docs/4.1/assets/js/src/search.js b/site/docs/4.1/assets/js/src/search.js
index 2e91fcf21..546cca5c7 100644
--- a/site/docs/4.1/assets/js/src/search.js
+++ b/site/docs/4.1/assets/js/src/search.js
@@ -12,6 +12,19 @@
var inputElement = document.getElementById('search-input')
var siteDocsVersion = inputElement.getAttribute('data-docs-version')
+ function getOrigin() {
+ var location = window.location
+ var origin = location.origin
+
+ if (!origin) {
+ var port = location.port ? ':' + location.port : ''
+
+ origin = location.protocol + '//' + location.hostname + port
+ }
+
+ return origin
+ }
+
window.docsearch({
apiKey: '5990ad008512000bba2cf951ccf0332f',
indexName: 'bootstrap',
@@ -27,11 +40,11 @@
},
transformData: function (hits) {
return hits.map(function (hit) {
- // When in production, return the result as is,
- // otherwise remove our url from it.
- var siteurl = inputElement.getAttribute('data-siteurl')
+ var siteurl = getOrigin()
var urlRE = /^https?:\/\/getbootstrap\.com/
+ // When in production, return the result as is,
+ // otherwise remove our url from it.
hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
return hit