multi-comments
This commit is contained in:
parent
8c8d3c1707
commit
adf73dd5ce
|
@ -1,37 +1,18 @@
|
|||
<%
|
||||
function layoutDiv() {
|
||||
const cmt = 'beaudar';
|
||||
// 合并配置参数
|
||||
var config = Object.assign({}, theme.comments[cmt]);
|
||||
if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj[cmt] != undefined) {
|
||||
Object.assign(config, proj[cmt]);
|
||||
}
|
||||
}
|
||||
Object.assign(config, page[cmt]);
|
||||
// 合并评论数据
|
||||
if (config['issue-number'] !== null) {
|
||||
config['issue-term'] = null;
|
||||
} else {
|
||||
if (page.comment_id != undefined) {
|
||||
config['issue-term'] = page.comment_id;
|
||||
} else if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.comment_id != undefined) {
|
||||
config['issue-term'] = proj.comment_id;
|
||||
var el = '';
|
||||
const cmt = page.cmt;
|
||||
if (cmt && cmt.service && (cmt.service.length > 0)) {
|
||||
const name = cmt.service;
|
||||
const body = cmt[name];
|
||||
el += '<div id="' + name + '"';
|
||||
for (let key of Object.keys(body)) {
|
||||
if (body[key] !== null) {
|
||||
el += ' ' + key + '="' + body[key] + '"';
|
||||
}
|
||||
}
|
||||
el += '></div>';
|
||||
}
|
||||
// 布局
|
||||
var el = '';
|
||||
el += '<div id="' + cmt + '"';
|
||||
for (let key of Object.keys(config)) {
|
||||
if (config[key] !== null) {
|
||||
el += ' ' + key + '="' + config[key] + '"';
|
||||
}
|
||||
}
|
||||
el += '></div>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -1,35 +1,18 @@
|
|||
<%
|
||||
function layoutDiv() {
|
||||
const cmt = 'giscus';
|
||||
// 合并配置参数
|
||||
var config = Object.assign({}, theme.comments[cmt]);
|
||||
if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj[cmt] != undefined) {
|
||||
Object.assign(config, proj[cmt]);
|
||||
}
|
||||
}
|
||||
Object.assign(config, page[cmt]);
|
||||
// 合并评论数据
|
||||
if (page.comment_id != undefined) {
|
||||
config['data-mapping'] = 'specific';
|
||||
config['data-term'] = page.comment_id;
|
||||
} else if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.comment_id != undefined) {
|
||||
config['data-mapping'] = 'specific';
|
||||
config['data-term'] = proj.comment_id;
|
||||
}
|
||||
}
|
||||
// 布局
|
||||
var el = '';
|
||||
el += '<div id="' + cmt + '"';
|
||||
for (let key of Object.keys(config)) {
|
||||
if (config[key] !== null) {
|
||||
el += ' ' + key + '="' + config[key] + '"';
|
||||
const cmt = page.cmt;
|
||||
if (cmt && cmt.service && (cmt.service.length > 0)) {
|
||||
const name = cmt.service;
|
||||
const body = cmt[name];
|
||||
el += '<div id="' + name + '"';
|
||||
for (let key of Object.keys(body)) {
|
||||
if (body[key] !== null) {
|
||||
el += ' ' + key + '="' + body[key] + '"';
|
||||
}
|
||||
}
|
||||
el += '></div>';
|
||||
}
|
||||
el += '></div>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
<%
|
||||
var cmt = {
|
||||
service: theme.comments.service
|
||||
};
|
||||
if (cmt.service) {
|
||||
cmt[cmt.service] = Object.assign({}, theme.comments[cmt.service]);
|
||||
}
|
||||
var loadComment = false;
|
||||
if (theme.comments.service && theme.comments.service.length > 0) {
|
||||
if (page.comments == undefined || page.comments != false) {
|
||||
|
@ -13,15 +19,24 @@ if (loadComment && page.layout == 'wiki' && page.wiki) {
|
|||
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]);
|
||||
}
|
||||
}
|
||||
if (cmt.service && page[cmt.service]) {
|
||||
Object.assign(cmt[cmt.service], page[cmt.service]);
|
||||
}
|
||||
page.cmt = cmt;
|
||||
%>
|
||||
<% if (loadComment) { %>
|
||||
<div class='related-wrap md reveal' id="comments">
|
||||
<div class='cmt-title cap theme'>
|
||||
<%- page.comment_title != undefined ? markdown(page.comment_title) : __('meta.comment_title') %>
|
||||
</div>
|
||||
<div class='cmt-body <%- theme.comments.service %>'>
|
||||
<%- partial(theme.comments.service + '/layout') %>
|
||||
<div class='cmt-body <%- cmt.service %>'>
|
||||
<%- partial(cmt.service + '/layout') %>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<% if (theme.comments.service && theme.comments.service.length > 0) { %>
|
||||
<%- partial(theme.comments.service + '/script') %>
|
||||
<% if (page.cmt && page.cmt.service && page.cmt.service.length > 0) { %>
|
||||
<%- partial(page.cmt.service + '/script') %>
|
||||
<% } %>
|
||||
|
|
|
@ -1,37 +1,18 @@
|
|||
<%
|
||||
function layoutDiv() {
|
||||
const cmt = 'utterances';
|
||||
// 合并配置参数
|
||||
var config = Object.assign({}, theme.comments[cmt]);
|
||||
if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj[cmt] != undefined) {
|
||||
Object.assign(config, proj[cmt]);
|
||||
}
|
||||
}
|
||||
Object.assign(config, page[cmt]);
|
||||
// 合并评论数据
|
||||
if (config['issue-number'] !== null) {
|
||||
config['issue-term'] = null;
|
||||
} else {
|
||||
if (page.comment_id != undefined) {
|
||||
config['issue-term'] = page.comment_id;
|
||||
} else if (page.layout === 'wiki' && page.wiki) {
|
||||
let proj = theme.wiki.projects[page.wiki];
|
||||
if (proj.comment_id != undefined) {
|
||||
config['issue-term'] = proj.comment_id;
|
||||
var el = '';
|
||||
const cmt = page.cmt;
|
||||
if (cmt && cmt.service && (cmt.service.length > 0)) {
|
||||
const name = cmt.service;
|
||||
const body = cmt[name];
|
||||
el += '<div id="' + name + '"';
|
||||
for (let key of Object.keys(body)) {
|
||||
if (body[key] !== null) {
|
||||
el += ' ' + key + '="' + body[key] + '"';
|
||||
}
|
||||
}
|
||||
el += '></div>';
|
||||
}
|
||||
// 布局
|
||||
var el = '';
|
||||
el += '<div id="' + cmt + '"';
|
||||
for (let key of Object.keys(config)) {
|
||||
if (config[key] !== null) {
|
||||
el += ' ' + key + '="' + config[key] + '"';
|
||||
}
|
||||
}
|
||||
el += '></div>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
|
|
Loading…
Reference in New Issue