This commit is contained in:
xaoxuu 2021-02-21 18:48:38 +08:00
parent ba4008e57d
commit c971cd4988
5 changed files with 30 additions and 20 deletions

View File

@ -33,8 +33,8 @@ meta:
footer:
license: '本博客所有文章除特别声明外,均采用 %s 许可协议。转载请注明出处!'
info_not_open_source: '本站由 %s 创建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作为主题。'
info_open_source: '本站由 %s 创建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作为主题,您可以在 [%s](%s) 找到本站源码。'
info_not_open_source: '本站由 %s 创建,使用 %s 作为主题。'
info_open_source: '本站由 %s 创建,使用 %s 作为主题,您可以在 %s 找到本站源码。'
page:
error:

View File

@ -33,8 +33,8 @@ meta:
footer:
license: '本網誌所有文章除特別聲明外,均採用 %s 許可協議。轉載請註明出處!'
info_not_open_source: '本站由 %s 創建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作為主題。'
info_open_source: '本站由 %s 創建,使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 作為主題,您可以在 [%s](%s) 找到本站源碼。'
info_not_open_source: '本站由 %s 創建,使用 %s 作為主題。'
info_open_source: '本站由 %s 創建,使用 %s 作為主題,您可以在 %s 找到本站源碼。'
page:
error:

View File

@ -1,5 +1,5 @@
<%
const author = '[' + config.author + '](' + config.url + config.root + ')';
const author = '[@' + config.author + '](' + config.url + config.root + ')';
const using = '[' + stellar_info('name') + '](' + stellar_info('tree') + ')';
const source = theme.footer.source;
function layoutDiv() {

View File

@ -8,9 +8,23 @@ if (page.utterances == undefined) {
}
}
}
if (page.comment_id) {
page.utterances['issue-term'] = page.comment_id;
}
if (theme.comments.utterances.theme) {
if (page.dark) {
page.utterances.theme = theme.comments.utterances.theme.dark;
} else {
page.utterances.theme = theme.comments.utterances.theme.light;
}
}
%>
<script>
function pjax_utterances(){
stellar.comments = {
service: 'utterances',
utterances: Object.assign(<%- JSON.stringify(page.utterances) %>),
}
function utterances(){
if(!document.getElementById("utterances"))return;
setTimeout(function() {
var checkUtterances = setInterval(function () {
@ -21,20 +35,16 @@ if (page.utterances == undefined) {
HEAD.innerHTML="";
} catch (error) {}
var script = document.createElement('script');
script.setAttribute('src','https://utteranc.es/client.js');
script.setAttribute('repo','<%- page.utterances.repo %>');
let issuenumber = '<%- page.utterances['issue-number'] || page.comment_id %>';
if (issuenumber) {
script.setAttribute('issue-term', issuenumber);
} else {
script.setAttribute('issue-term', '<%- page.utterances['issue-term'] %>');
const keys = ['repo', 'issue-term', 'theme', 'label', 'crossorigin'];
script.src = 'https://utteranc.es/client.js';
for (let key of Object.keys(stellar.comments.utterances)) {
if (keys.includes(key) && stellar.comments.utterances[key]) {
script.setAttribute(key, stellar.comments.utterances[key]);
}
}
script.setAttribute('theme', '<%- page.dark ? page.utterances.theme.dark : page.utterances.theme.light %>' );
script.setAttribute('label','<%- page.utterances.label %>');
script.setAttribute('crossorigin','<%- page.utterances.crossorigin %>');
HEAD.appendChild(script);
}, 200)
});
}
pjax_utterances();
utterances();
</script>

View File

@ -98,7 +98,7 @@ const util = {
// 从 butterfly 和 volantis 获得灵感
loadScript: (src, opt) => new Promise((resolve, reject) => {
const script = document.createElement('script')
var script = document.createElement('script')
script.src = src
if (opt) {
for (let key of Object.keys(opt)) {
@ -284,8 +284,8 @@ if (stellar.plugins.swiper) {
if (stellar.plugins.preload) {
if (stellar.plugins.preload.service == 'instant_page') {
util.loadScript(stellar.plugins.preload.instant_page, {
defer:true,
type:'module',
defer: true,
type: 'module',
integrity: 'sha384-OeDn4XE77tdHo8pGtE1apMPmAipjoxUQ++eeJa6EtJCfHlvijigWiJpD7VDPWXV1'
})
} else if (stellar.plugins.preload.service == 'flying_pages') {