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

43 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
2022-11-14 00:28:48 +08:00
var cmt = {
service: theme.comments.service
};
if (cmt.service) {
cmt[cmt.service] = Object.assign({}, theme.comments[cmt.service]);
}
2021-02-19 23:33:19 +08:00
var loadComment = false;
if (theme.comments.service && theme.comments.service.length > 0) {
if (page.comments == undefined || page.comments != false) {
loadComment = true;
}
}
// 合并项目评论
2021-07-26 22:26:46 +08:00
if (loadComment && page.layout == 'wiki' && page.wiki) {
2021-07-13 23:45:34 +08:00
let proj = theme.wiki.projects[page.wiki];
2021-07-26 22:26:46 +08:00
if (proj.comment_title != undefined && page.comment_title == undefined) {
2022-08-28 19:54:34 +08:00
if (['utterances', 'beaudar', 'giscus'].includes(theme.comments.service)) {
2021-07-13 23:45:34 +08:00
page.comment_title = proj.comment_title;
2021-02-19 23:33:19 +08:00
}
}
2022-11-14 00:28:48 +08:00
if (proj.comments && proj.comments.service) {
cmt = proj.comments;
let s = proj.comments.service;
cmt[s] = Object.assign({}, theme.comments[s], proj.comments[s]);
}
}
if (cmt.service && page[cmt.service]) {
Object.assign(cmt[cmt.service], page[cmt.service]);
2021-02-19 23:33:19 +08:00
}
2022-11-14 00:28:48 +08:00
page.cmt = cmt;
2021-02-19 23:33:19 +08:00
%>
<% if (loadComment) { %>
2022-11-23 22:44:11 +08:00
<div class='related-wrap md-text reveal' id="comments">
2021-02-28 18:19:32 +08:00
<div class='cmt-title cap theme'>
2021-07-26 22:26:46 +08:00
<%- page.comment_title != undefined ? markdown(page.comment_title) : __('meta.comment_title') %>
2021-02-19 23:33:19 +08:00
</div>
2022-11-14 00:28:48 +08:00
<div class='cmt-body <%- cmt.service %>'>
<%- partial(cmt.service + '/layout') %>
2021-02-19 23:33:19 +08:00
</div>
2021-02-25 20:49:43 +08:00
</div>
2021-02-19 23:33:19 +08:00
<% } %>