Compare commits

...
Sign in to create a new pull request.

7 commits

Author SHA1 Message Date
XhmikosR
9b50f69386
Merge branch 'main' into master-mc-opensearch 2020-12-08 22:33:45 +02:00
XhmikosR
19f3b4a2e5 Revert "Add OpenSearch images" 2020-11-20 21:00:54 +02:00
XhmikosR
c29cd7f770 Add OpenSearch images 2020-11-20 21:00:43 +02:00
XhmikosR
f02783af30 Add InputEncoding 2020-11-20 21:00:42 +02:00
XhmikosR
648538b5cc Update search.js 2020-11-20 21:00:42 +02:00
XhmikosR
66c11808b2 Make OpenSearch an output format.
Not sure if there's another way to do this...
2020-11-20 21:00:36 +02:00
Martijn Cuppens
be0c4e1d30 docs: enable OpenSearch 2020-11-20 21:00:35 +02:00
4 changed files with 39 additions and 1 deletions

View file

@ -20,6 +20,18 @@ enableRobotsTXT: true
metaDataFormat: "yaml"
disableKinds: ["404", "taxonomy", "taxonomyTerm", "RSS"]
outputFormats:
OpenSearch:
baseName: opensearch
isPlainText: true
mediaType: application/xml
notAlternative: true
outputs:
home:
- HTML
- OpenSearch
publishDir: "_gh_pages"
module:

View file

@ -20,7 +20,7 @@
}
})
window.docsearch({
var search = window.docsearch({
apiKey: '5990ad008512000bba2cf951ccf0332f',
indexName: 'bootstrap',
inputSelector: '#search-input',
@ -50,4 +50,18 @@
// Set debug to `true` if you want to inspect the dropdown
debug: false
})
function hashSearch() {
var SEARCH_WORD = '#search='
if (window.location.hash && window.location.hash.startsWith(SEARCH_WORD)) {
search.input.autocomplete.setVal(window.location.hash.slice(SEARCH_WORD.length))
search.input.autocomplete.open()
}
}
hashSearch()
// For the nerds: search by changing the url hash
window.addEventListener('hashchange', hashSearch, false)
})()

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>{{ .Site.Title }}</ShortName>
<Description>Search {{ .Site.Title }} documentation</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image type="image/x-icon" width="16" height="16">{{ (printf "/docs/%s/assets/img/favicons/favicon.ico" .Site.Params.docs_version) | absURL }}</Image>
<Url type="text/html" method="get" template="{{ (printf "/docs/%s/getting-started/introduction/" .Site.Params.docs_version) | absURL }}#search={searchTerms}"/>
</OpenSearchDescription>

View file

@ -11,6 +11,10 @@
<link rel="canonical" href="{{ .Permalink }}">
{{ with .OutputFormats.Get "opensearch" -}}
<link rel="search" href="{{ .Permalink }}" title="{{ $.Site.Title }}" type="application/opensearchdescription+xml">
{{ end -}}
{{ with .Params.robots -}}
<meta name="robots" content="{{ . }}">
{{- end }}