Skip to content

Commit

Permalink
Merge branch 'v4-dev' into v4-dev-xmr-pck-var
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 20, 2018
2 parents b4e3462 + 282b77e commit 759ee65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion site/_includes/docs-sidebar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form class="bd-search d-flex align-items-center">
<input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off" data-siteurl="{{ site.url }}" data-docs-version="{{ site.docs_version }}">
<input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off" data-docs-version="{{ site.docs_version }}">
<button class="btn btn-link bd-search-docs-toggle d-md-none p-0 ml-3" type="button" data-toggle="collapse" data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="false" aria-label="Toggle docs navigation">
{%- include icons/menu.svg width="30" height="30" -%}
</button>
Expand Down
19 changes: 16 additions & 3 deletions site/docs/4.1/assets/js/src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit 759ee65

Please sign in to comment.