hexo-theme-stellar/layout/_partial/widgets/search.ejs

32 lines
968 B
Plaintext
Raw Normal View History

2022-11-27 17:16:38 +08:00
<%
function layoutDiv() {
var el = '<widget class="widget-wrapper search">'
el += '<div class="widget-body">'
el += '<div class="search-wrapper" id="search">'
el += '<form class="search-form">'
var filter = ''
if (item.filter == 'auto' && page.layout == 'wiki') {
let matches = page.path.match(/(.*?)\/(.*?)\//i)
if (matches?.length > 0) {
filter = matches[0]
}
}
el += '<input type="text" class="search-input" id="search-input"'
if (filter.length > 0) {
filter = '/' + filter
el += ' data-filter="' + filter + '"'
el += ' placeholder="' + (item.placeholder || __('search.search_in', filter)) + '">'
} else {
el += ' placeholder="' + (item.placeholder || __('search.search')) + '">'
}
el += '</form>'
el += '<div id="search-result"></div>'
el += '<div class="search-no-result">' + __('search.no_results') + '</div>'
el += '</div>'
el += '</div>'
el += '</widget>'
return el
}
%>
<%- layoutDiv() %>