add theme
This commit is contained in:
29
themes/butterfly/layout/includes/third-party/search/docsearch.pug
vendored
Normal file
29
themes/butterfly/layout/includes/third-party/search/docsearch.pug
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
- const { placeholder, docsearch: { appId, apiKey, indexName, option } } = theme.search
|
||||
|
||||
.docsearch-wrap
|
||||
#docsearch(style="display:none")
|
||||
link(rel="stylesheet" href=url_for(theme.asset.docsearch_css))
|
||||
script(src=url_for(theme.asset.docsearch_js))
|
||||
script.
|
||||
(() => {
|
||||
docsearch(Object.assign({
|
||||
appId: '!{appId}',
|
||||
apiKey: '!{apiKey}',
|
||||
indexName: '!{indexName}',
|
||||
container: '#docsearch',
|
||||
placeholder: '!{ placeholder || _p("search.input_placeholder")}',
|
||||
}, !{JSON.stringify(option)}))
|
||||
|
||||
const handleClick = () => {
|
||||
document.querySelector('.DocSearch-Button').click()
|
||||
}
|
||||
|
||||
const searchClickFn = () => {
|
||||
btf.addEventListenerPjax(document.querySelector('#search-button > .search'), 'click', handleClick)
|
||||
}
|
||||
|
||||
searchClickFn()
|
||||
window.addEventListener('pjax:complete', searchClickFn)
|
||||
})()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user