2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-05 16:42:29 +03:00

Alternative solution.

Rely on `site.url` which is different for production. In that case do nothing with the search result, otherwise when in development remove our url from it.
This commit is contained in:
XhmikosR
2018-03-14 19:44:32 +02:00
parent 483e49e3c6
commit b9577a1cf7
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -115,8 +115,13 @@
},
transformData: function (hits) {
return hits.map(function (hit) {
var baseurl = document.getElementById('search-input').getAttribute('data-baseurl')
hit.url = hit.url.replace('https://getbootstrap.com' + baseurl, baseurl)
// When in production, return the result as is,
// otherwise remove our url from it.
var siteurl = document.getElementById('search-input').getAttribute('data-siteurl')
var urlRE = /^https?:\/\/getbootstrap\.com/
hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
return hit
})
},