feat(nesting): max 4 layer nesting

0.2.5(deprecated)
SukkaW 7 years ago
parent 73979a366b
commit 0b1ebbc02c

@ -487,8 +487,6 @@ function renderComment(data) {
`; `;
document.getElementById('disqus_thread').innerHTML = disqusjsBaseTpl; document.getElementById('disqus_thread').innerHTML = disqusjsBaseTpl;
var commentBodyTpl = ` var commentBodyTpl = `
<div class="dsqjs-item-container"> <div class="dsqjs-item-container">
<div class="dsqjs-avater"> <div class="dsqjs-avater">
@ -504,14 +502,26 @@ function renderComment(data) {
</div> </div>
</div> </div>
` `
data.map(s => { data.map(s => {
childrenComments = (s) => { childrenComments = (s) => {
var nesting = s.nesting
var children = (s.children || []); var children = (s.children || []);
if (typeof children === 'null') return;
var html = '<ul class="dsqjs-list dsqjs-children">'; if (typeof children === 'null') {
console.log(children) return;
}
console.log(nesting < 4)
if (nesting < 4) {
var html = '<ul class="dsqjs-list dsqjs-children">';
} else {
var html = '<ul class="dsqjs-list">';
}
children.map(s => { children.map(s => {
let comment = s.comment let comment = s.comment
if (comment.author.profileUrl) { if (comment.author.profileUrl) {
@ -526,7 +536,9 @@ function renderComment(data) {
comment.authorEl = `${comment.author.name}` comment.authorEl = `${comment.author.name}`
} }
html += '<li class="dsqjs-item" id="comment-${comment.id}">' s.nesting = nesting + 1
html += `<li class="dsqjs-item" id="comment-${comment.id}">`
html += baidu.template(commentBodyTpl, comment) html += baidu.template(commentBodyTpl, comment)
@ -557,7 +569,11 @@ function renderComment(data) {
comment.authorEl = `${comment.author.name}` comment.authorEl = `${comment.author.name}`
} }
let html = '<li class="dsqjs-item" id="comment-${comment.id}">' if (s.children) {
s.nesting = 1
}
let html = `<li class="dsqjs-item" id="comment-${comment.id}">`
html += baidu.template(commentBodyTpl, comment) html += baidu.template(commentBodyTpl, comment)

@ -90,7 +90,7 @@
word-wrap: break-word; word-wrap: break-word;
} }
#dsqjs .dsqjs-children .dsqjs-item { #dsqjs .dsqjs-children>.dsqjs-item {
margin-left: 60px; margin-left: 60px;
} }

Loading…
Cancel
Save