feat: 重構本地搜索

feat: Algolia 搜索,點擊文章內容也會跳轉到相應頁面
fix: 修復 fullpage loading 顯示滾動條的 bug close #1235
fix: 修復 safari 下,搜索內容被系統搜索框遮擋的 bug
improvement: 手機 safari 橫屏時,網頁全屏幕顯示
improvement: 當沒有開啟 beautify 時, hr 顯示默認的樣式
This commit is contained in:
Jerry
2023-03-28 20:40:43 +08:00
parent 63dc605794
commit 8199e25215
21 changed files with 426 additions and 226 deletions

View File

@@ -59,3 +59,5 @@ div
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src= theme.asset.busuanzi || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
!=partial('includes/third-party/search/index', {}, {cache: true})

View File

@@ -15,7 +15,7 @@
meta(charset='UTF-8')
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0")
meta(name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,viewport-fit=cover")
title= tabTitle
meta(name="author" content=pageAuthor)
meta(name="copyright" content=pageCopyright)

View File

@@ -21,9 +21,12 @@
localSearch = JSON.stringify({
path: theme.local_search.CDN ? theme.local_search.CDN : config.root + config.search.path,
preload: theme.local_search.preload,
top_n_per_article: theme.local_search.top_n_per_article,
unescape: theme.local_search.unescape,
languages: {
// search languages
hits_empty: _p("search.local_search.hits_empty"),
hits_stats: _p("search.local_search.hits_stats"),
}
})
}

View File

@@ -44,5 +44,4 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
include ./404.pug
include ./rightside.pug
include ./additional-js.pug
!=partial('includes/third-party/search/index', {}, {cache: true})
include ./additional-js.pug

View File

@@ -11,15 +11,16 @@
script.
const preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.body.style.overflow = '';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.body.style.overflow = 'hidden';
document.getElementById('loading-box').classList.remove("loaded")
}
}
preloader.initLoading()
window.addEventListener('load',()=> { preloader.endLoading() })
if (!{theme.pjax && theme.pjax.enable}) {

View File

@@ -15,8 +15,8 @@
.local-search-box
input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input
hr
#local-search-results
#local-search-results.no-result
#local-search-stats-wrap
#search-mask
script(src=url_for(theme.asset.local_search))