hexo-theme-stellar/layout/_partial/plugins/comments/utterances/layout.ejs

42 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-02-21 23:20:13 +08:00
<%
function layoutDiv() {
2021-07-23 12:10:24 +08:00
const cmt = 'utterances';
// 合并配置参数
var config = Object.assign({}, theme.comments[cmt]);
if (page.layout === 'wiki' && page.wiki) {
let proj = theme.wiki.projects[page.wiki];
2021-07-26 22:26:46 +08:00
if (proj[cmt] != undefined) {
2021-07-23 12:10:24 +08:00
Object.assign(config, proj[cmt]);
}
2021-02-21 23:20:13 +08:00
}
2021-07-23 12:10:24 +08:00
Object.assign(config, page[cmt]);
// 合并评论数据
if (config['issue-number'] !== null) {
config['issue-term'] = null;
} else {
2021-07-26 22:26:46 +08:00
if (page.comment_id != undefined) {
2021-07-23 12:10:24 +08:00
config['issue-term'] = page.comment_id;
} else if (page.layout === 'wiki' && page.wiki) {
let proj = theme.wiki.projects[page.wiki];
2021-07-26 22:26:46 +08:00
if (proj.comment_id != undefined) {
2021-07-23 12:10:24 +08:00
config['issue-term'] = proj.comment_id;
}
}
2021-02-22 22:03:02 +08:00
}
2021-07-23 12:10:24 +08:00
// 布局
var el = '';
el += '<div id="' + cmt + '"';
for (let key of Object.keys(config)) {
if (config[key] !== null) {
el += ' ' + key + '="' + config[key] + '"';
2021-02-21 23:20:13 +08:00
}
}
el += '></div>';
return el;
}
%>
2021-02-23 21:09:49 +08:00
<svg class="loading" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2709"><path d="M832 512c0-176-144-320-320-320V128c211.2 0 384 172.8 384 384h-64zM192 512c0 176 144 320 320 320v64C300.8 896 128 723.2 128 512h64z" p-id="2710"></path></svg>
2021-02-21 23:20:13 +08:00
<%- layoutDiv() %>