0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

add docsearch

This commit is contained in:
Maxime Locqueville 2017-05-28 18:50:53 +02:00 committed by Mark Otto
parent 10ca9c6d5a
commit c709ce19a5
3 changed files with 13 additions and 38 deletions

View File

@ -35,17 +35,17 @@
<script src="{{ site.baseurl }}/assets/js/ie10-viewport-bug-workaround.js"></script> <script src="{{ site.baseurl }}/assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="{{ site.baseurl }}/assets/js/ie-emulation-modes-warning.js"></script> <script src="{{ site.baseurl }}/assets/js/ie-emulation-modes-warning.js"></script>
<script src="{{ site.baseurl }}/assets/js/vendor/jekyll-search.min.js"></script> {% if page.layout == "docs" %}
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
<script> <script>
SimpleJekyllSearch.init({ docsearch({
searchInput: document.getElementById('search-input'), apiKey: '48cb48b22351bc71ea5f12f4d1ede198',
resultsContainer: document.getElementById('search-results'), indexName: 'bootstrap-v4',
searchResultTemplate: '<a class="dropdown-item" href="{url}">{title}</a>', inputSelector: '#search-input',
noResultsText: '<div class="dropdown-item no-results">Sorry, there are no results for that search.</div>', debug: true // Set debug to true if you want to inspect the dropdown
json: '{{ site.baseurl }}/search.json' });
})
</script> </script>
{% endif %}
<script> <script>
Holder.addTheme('gray', { Holder.addTheme('gray', {

View File

@ -19,6 +19,9 @@
{% endif %} {% endif %}
<!-- Documentation extras --> <!-- Documentation extras -->
{% if page.layout == "docs" %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" />
{% endif %}
<link href="{{ site.baseurl }}/assets/css/docs.min.css" rel="stylesheet"> <link href="{{ site.baseurl }}/assets/css/docs.min.css" rel="stylesheet">
<!-- Favicons --> <!-- Favicons -->

View File

@ -64,39 +64,11 @@
} }
.bd-search { .bd-search {
position: relative; position: relative; // To contain the Algolia search
padding-top: 1rem; padding-top: 1rem;
padding-bottom: 1rem; padding-bottom: 1rem;
} }
.bd-search-results {
right: 0;
display: block;
padding: 0;
overflow: hidden;
font-size: .85rem;
&:empty {
display: none;
}
.dropdown-item {
padding-right: .75rem;
padding-left: .75rem;
&:first-child { margin-top: .25rem; }
&:last-child { margin-bottom: .25rem; }
}
.no-results {
padding: .75rem 1rem;
color: #7a7a7a;
text-align: center;
white-space: normal; // Undo .dropdown-item defaults
}
}
.bd-sidenav { .bd-sidenav {
display: none; display: none;
} }