if (relatedPosts.length > 0) { result += '<div class="relatedPosts">' result += `<div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>${headlineLang}</span></div>` result += '<div class="relatedPosts-list">'
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) { const cover = relatedPosts[i].cover === false ? relatedPosts[i].randomcover : relatedPosts[i].cover const title = this.escape_html(relatedPosts[i].title) const description = this.strip_html(relatedPosts[i].description) const content = this.strip_html(relatedPosts[i].content) result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${title}">` result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">` if (dateType === 'created') { result += `<div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> ${this.date(relatedPosts[i].created, hexoConfig.date_format)}</div>` } else { result += `<div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</div>` } result += `<div class="title">${title}</div>` switch (config.index_post_content.method) { casefalse: break case1: result += `<div class="info">${description}</div>` break case2: if (description) { result += `<div class="info">${description}</div>` } else { let expert = content.substring(0, config.index_post_content.length) content.length > config.index_post_content.length ? expert += ' ...' : '' result += `<div class="info">${expert}</div>` } break default: let expert = content.substring(0, config.index_post_content.length) content.length > config.index_post_content.length ? expert += ' ...' : '' result += `<div class="info">${expert}</div>` break } result += '</div></a></div>' } result += '</div></div>' return result } })
functionisTagRelated (tagName, TBDtags) { let result = false TBDtags.forEach(function (tag) { if (tagName === tag.name) { result = true } }) return result }
functionfindItem (arrayToSearch, attr, val) { for (let i = 0; i < arrayToSearch.length; i++) { if (arrayToSearch[i][attr] === val) { return i } } return -1 }