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

48 lines
1.4 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;
}
}
// 合并项目评论
2024-01-19 01:05:44 +08:00
const proj = theme.wiki.tree[page.wiki]
if (loadComment && (proj != null)) {
if (proj.comments === false) {
loadComment = false;
page.comments = false;
} else {
if (proj.comment_title != undefined && page.comment_title == undefined) {
if (['utterances', 'beaudar', 'giscus'].includes(theme.comments.service)) {
page.comment_title = proj.comment_title;
}
}
if (proj.comments && proj.comments.service) {
cmt = proj.comments;
let s = proj.comments.service;
cmt[s] = Object.assign({}, theme.comments[s], proj.comments[s]);
2021-02-19 23:33:19 +08:00
}
2022-11-14 00:28:48 +08:00
}
}
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) { %>
2024-01-19 01:05:44 +08:00
<div class="related-wrap md-text<%- scrollreveal(' ') %>" id="comments">
2022-12-12 21:07:22 +08:00
<section class='header cmt-title cap theme'>
2024-02-06 23:51:08 +08:00
<%- markdown(page.comment_title || theme.comments.comment_title) %>
2022-12-12 21:07:22 +08:00
</section>
<section class='body cmt-body <%- cmt.service %>'>
2022-11-14 00:28:48 +08:00
<%- partial(cmt.service + '/layout') %>
2022-12-12 21:07:22 +08:00
</section>
2021-02-25 20:49:43 +08:00
</div>
2021-02-19 23:33:19 +08:00
<% } %>