You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.7 KiB
133 lines
4.7 KiB
9 months ago
|
-
|
||
|
let algolia = 'undefined';
|
||
|
let env = process.env;
|
||
|
if (theme.algolia_search.enable) {
|
||
|
algolia = JSON.stringify({
|
||
|
appId: env.ALGOLIA_APP_ID || config.algolia.appId || config.algolia.applicationID,
|
||
|
apiKey: env.ALGOLIA_API_KEY || config.algolia.apiKey,
|
||
|
indexName: env.ALGOLIA_INDEX_NAME || config.algolia.indexName,
|
||
|
hits: theme.algolia_search.hits,
|
||
|
// search languages
|
||
|
languages: {
|
||
|
input_placeholder: _p("search.algolia_search.input_placeholder"),
|
||
|
hits_empty: _p("search.algolia_search.hits_empty"),
|
||
|
hits_stats: _p("search.algolia_search.hits_stats"),
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
let localSearch = 'undefined';
|
||
|
if (theme.local_search && theme.local_search.enable) {
|
||
|
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"),
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
let translate = 'undefined';
|
||
|
if (theme.translate && theme.translate.enable){
|
||
|
translate = JSON.stringify({
|
||
|
defaultEncoding: theme.translate.defaultEncoding,
|
||
|
translateDelay: theme.translate.translateDelay,
|
||
|
msgToTraditionalChinese: theme.translate.msgToTraditionalChinese,
|
||
|
msgToSimplifiedChinese: theme.translate.msgToSimplifiedChinese
|
||
|
})
|
||
|
}
|
||
|
|
||
|
let copyright = 'undefined';
|
||
|
if (theme.copy.enable && theme.copy.copyright.enable){
|
||
|
copyright = JSON.stringify({
|
||
|
limitCount: theme.copy.copyright.limit_count,
|
||
|
languages: {
|
||
|
author: _p("copy_copyright.author") + ': ' + config.author,
|
||
|
link: _p("copy_copyright.link") + ': ',
|
||
|
source: _p("copy_copyright.source") + ': ' + config.title,
|
||
|
info: _p("copy_copyright.info")
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
let Snackbar = 'undefined';
|
||
|
if (theme.snackbar && theme.snackbar.enable) {
|
||
|
Snackbar = JSON.stringify({
|
||
|
chs_to_cht: _p("Snackbar.chs_to_cht"),
|
||
|
cht_to_chs: _p("Snackbar.cht_to_chs"),
|
||
|
day_to_night: _p("Snackbar.day_to_night"),
|
||
|
night_to_day: _p("Snackbar.night_to_day"),
|
||
|
bgLight: theme.snackbar.bg_light,
|
||
|
bgDark: theme.snackbar.bg_dark,
|
||
|
position: theme.snackbar.position,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
let noticeOutdate = 'undefined';
|
||
|
if (theme.noticeOutdate && theme.noticeOutdate.enable) {
|
||
|
noticeOutdate = JSON.stringify({
|
||
|
limitDay: theme.noticeOutdate.limit_day,
|
||
|
position: theme.noticeOutdate.position,
|
||
|
messagePrev: theme.noticeOutdate.message_prev,
|
||
|
messageNext: theme.noticeOutdate.message_next,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
let highlight = 'undefined';
|
||
|
let syntaxHighlighter = config.syntax_highlighter;
|
||
|
let highlightEnable = syntaxHighlighter ? ['highlight.js', 'prismjs'].includes(syntaxHighlighter) : (config.highlight.enable || config.prismjs.enable);
|
||
|
if (highlightEnable) {
|
||
|
highlight = JSON.stringify({
|
||
|
plugin: syntaxHighlighter ? syntaxHighlighter : config.highlight.enable ? 'highlight.js' : 'prismjs',
|
||
|
highlightCopy: theme.highlight_copy,
|
||
|
highlightLang: theme.highlight_lang,
|
||
|
highlightHeightLimit: theme.highlight_height_limit
|
||
|
})
|
||
|
}
|
||
|
|
||
|
script.
|
||
|
const GLOBAL_CONFIG = {
|
||
|
root: '!{config.root}',
|
||
|
algolia: !{algolia},
|
||
|
localSearch: !{localSearch},
|
||
|
translate: !{translate},
|
||
|
noticeOutdate: !{noticeOutdate},
|
||
|
highlight: !{highlight},
|
||
|
copy: {
|
||
|
success: '!{_p("copy.success")}',
|
||
|
error: '!{_p("copy.error")}',
|
||
|
noSupport: '!{_p("copy.noSupport")}'
|
||
|
},
|
||
|
relativeDate: {
|
||
|
homepage: !{theme.post_meta.page.date_format === 'relative'},
|
||
|
post: !{theme.post_meta.post.date_format === 'relative'}
|
||
|
},
|
||
|
runtime: '!{theme.runtimeshow.enable ? _p("aside.card_webinfo.runtime.unit") : ""}',
|
||
|
dateSuffix: {
|
||
|
just: '!{_p("date_suffix.just")}',
|
||
|
min: '!{_p("date_suffix.min")}',
|
||
|
hour: '!{_p("date_suffix.hour")}',
|
||
|
day: '!{_p("date_suffix.day")}',
|
||
|
month: '!{_p("date_suffix.month")}'
|
||
|
},
|
||
|
copyright: !{copyright},
|
||
|
lightbox: '!{ theme.medium_zoom ? "mediumZoom" : (theme.fancybox ? "fancybox" : "null" )}',
|
||
|
Snackbar: !{Snackbar},
|
||
|
infinitegrid: {
|
||
|
js: '!{url_for(theme.asset.egjs_infinitegrid)}',
|
||
|
buttonText: '!{_p("load_more")}'
|
||
|
},
|
||
|
isPhotoFigcaption: !{theme.photofigcaption},
|
||
|
islazyload: !{theme.lazyload.enable},
|
||
|
isAnchor: !{theme.anchor.auto_update || false},
|
||
|
percent: {
|
||
|
toc: !{theme.toc.scroll_percent},
|
||
|
rightside: !{theme.rightside_scroll_percent},
|
||
|
},
|
||
|
autoDarkmode: !{theme.darkmode.enable && theme.darkmode.autoChangeMode === 1}
|
||
|
}
|