0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Enable docsearch in development env.

Previously a search redirected to `https://getbootstrap.com/...`
This commit is contained in:
m5o 2018-03-07 16:30:13 +02:00 committed by XhmikosR
parent d01b4eb025
commit 483e49e3c6
2 changed files with 3 additions and 2 deletions

View File

@ -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">
<input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off" data-baseurl="{{ site.baseurl }}/docs/{{ 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>

View File

@ -115,7 +115,8 @@
},
transformData: function (hits) {
return hits.map(function (hit) {
hit.url = hit.url.replace('https://v4-alpha.getbootstrap.com', '/docs/4.0')
var baseurl = document.getElementById('search-input').getAttribute('data-baseurl')
hit.url = hit.url.replace('https://getbootstrap.com' + baseurl, baseurl)
return hit
})
},