diff --git a/site/assets/js/search.js b/site/assets/js/search.js index d88263d3f..b7ab91eba 100644 --- a/site/assets/js/search.js +++ b/site/assets/js/search.js @@ -20,7 +20,7 @@ } }) - window.docsearch({ + var search = window.docsearch({ apiKey: '5990ad008512000bba2cf951ccf0332f', indexName: 'bootstrap', inputSelector: '#search-input', @@ -50,4 +50,15 @@ // Set debug to `true` if you want to inspect the dropdown debug: false }) + + function hashSearch() { + if (window.location.hash && window.location.hash.indexOf('#search=') === 0) { + search.input.autocomplete.setVal(window.location.hash.slice(8)) + search.input.autocomplete.open() + } + } + + hashSearch() + // For the nerds: search by changing the url hash + window.addEventListener('hashchange', hashSearch, false) })() diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html index 2d2eb29d9..114112f80 100644 --- a/site/layouts/partials/header.html +++ b/site/layouts/partials/header.html @@ -10,6 +10,7 @@ {{ if .IsHome }}{{ .Site.Title | markdownify }} · {{ .Site.Params.description | markdownify }}{{ else }}{{ .Title | markdownify }} · {{ .Site.Title | markdownify }} v{{ .Site.Params.docs_version }}{{ end }} + {{ with .Params.robots -}} diff --git a/site/static/documentation-search.xml b/site/static/documentation-search.xml new file mode 100644 index 000000000..9fdd82d49 --- /dev/null +++ b/site/static/documentation-search.xml @@ -0,0 +1,7 @@ + + + Bootstrap Documentation + Search in the latest Bootstrap documentation + https://deploy-preview-29872--twbs-bootstrap.netlify.com/favicon.ico + +