themes\stellar\layout\_partial\main\post_list\post_card.ejs// meta el += '<div class="meta cap">'; el += '<span class="cap" id="post-meta">'; el += icon('default: calendar') // time el += `<time datetime="${date_xml(post.date)}">${date(post.date, config.date_format)}</time>` <!-- 新增字数统计 新增一行--> el += '<span class="post-count"> '+ wordcount(post.content) +' 字 </span>'; el += '</span>';
<% const poster = post.poster; var obj = { image: post.cover }; if (poster) { obj.headline = poster.headline; obj.topic = poster.topic; obj.caption = poster.caption; obj.color = poster.color; } functiondiv_default() { var el = ''; el += '<article class="md-text" >';
// 封面 if (obj.image || theme.article.auto_cover) { var cover_url; if (obj.image != undefined) { if (obj.image.includes('/')) { cover_url = obj.image; } else { cover_url = 'https://source.unsplash.com/1280x640/?' + obj.image; } } else { // 自动以 tags 作为关键词搜索封面 if (post.tags) { var params = ''; post.tags.reverse().forEach((tag, i) => { if (i > 0) { params += ','; } params += tag.name; }); cover_url = 'https://source.unsplash.com/1280x640/?' + params; } else { cover_url = 'https://source.unsplash.com/random/1280x640'; } } if (cover_url) { el += '<div class="post-cover">'; el += '<img src="' + cover_url + '"/>'; el += '</div>'; } }
// 标题 el += '<h2 class="post-title">'; el += post.title ? post.title : date(post.date, config.date_format); el += '</h2>';
// 摘要 el += '<div class="excerpt'; if (theme.plugins.heti?.enable) { el += ' heti'; } el += '">'; el += '<p>'; if (post.excerpt) { el += strip_html(post.excerpt); } elseif (post.description) { el += post.description; } elseif (post.content && theme.article.auto_excerpt > 0) { el += truncate(strip_html(post.content), {length: theme.article.auto_excerpt}); } el += '</p>'; el += '</div>';
// meta el += '<div class="meta cap" >'; el += '<span class="cap" id="post-meta" style="font-size: 0.9rem;"> '; el += icon('default:calendar') // time el += `<time datetime="${date_xml(post.date)}">${date(post.date, config.date_format)}</time>` el += '<span class="post-count"> '+ wordcount(post.content) +' 字 </span>'; el += '</span>'; // cat if (post.categories && post.categories.length > 0) { if (post.layout === 'post' && post.categories && post.categories.length > 0) { var cats = []; if (post.categories) { post.categories.forEach((cat, i) => { cats.push(cat.name); }); } if (cats.length > 0) { let cat = cats.shift(); // 获取原始样式并添加字体大小 let style = category_color(cat); // 删除最后一个字符 style = style.slice(0, -1); style += ';font-size: 0.9rem"'; // 添加字体大小并加回引号 el += '<span class="cap breadcrumb" ' + style + '>'; el += icon('default:category') el += `<span>${cat}</span>` el += '</span>'; } } } // 新增:标签显示 // tags if (post.layout === 'post' && post.tags && post.tags.length > 0) { post.tags.forEach((tag, i) => { el += '<span style="font-size: 0.9rem;margin-right: 4px; border-radius: 7px;">'; el += '<span style="color: #1eb4ef; margin-right: 2px;">#</span>'; el += '<span style="color: #1eb4ef;">' + tag.name + '</span>'; el += '</span>'; }); }
if (post.sticky) { el += `<span class="pin">${icon('default:pin')}</span>` } el += '</div>'; el += '</article>'; return el; } functiondiv_photo() { var el = ''; el += '<div class="cover">'; el += '<img src="' + obj.image + '"/>'; if (obj.headline || obj.topic || obj.caption) { el += '<div class="cover-info"'; if (obj.color) { el += 'style="color:' + obj.color + '"'; } if (obj.topic) { el += 'position="top">'; } else { el += 'position="bottom">'; } if (obj.topic) { el += '<div class="cap">' + obj.topic + '</div>'; } if (obj.headline) { el += '<div class="title">' + obj.headline + '</div>'; } if (obj.caption) { el += '<div class="cap">' + obj.caption + '</div>'; } el += '</div>';
functionlayoutTocHeader(title) { var el = '' el += `<div class="widget-header dis-select">` el += `<span class="name">${title || __("meta.toc")}</span>` el += `<a class="cap-action" onclick="sidebar.toggleTOC()" >${icon('default:rightbar')}</a>` el += `</div>` return el }
functionlayoutToc(fallback) { const tocBody = layoutTocBody() if (tocBody.length == 0) { return'' } var el = '' el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">` el += layoutTocHeader() el += `<div class="widget-body">` el += tocBody el += `</div>` el += `</widget>` return el }
functionlayoutDiv(fallback) { console.log(page)
const editBtn = partial('components/edit', {map: item.edit_this_page}) const tocBody = layoutTocBody() if (tocBody.trim().length == 0 && editBtn.trim().length == 0) { return'' } var el = '' el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">` if (tocBody.length > 0) { el += layoutTocHeader() el += `<div class="widget-body">` el += tocBody el += `</div>` } el += `<div class="widget-footer">` el += editBtn el += `<a class="top" onclick="util.scrollTop()">` el += icon('default:upup') el += `<span>${__('btn.top')}</span>` el += `</a>` if (theme.comments.service && theme.comments.service.length > 0) { if (page.comments == undefined || page.comments != false) { el += `<a class="buttom" onclick="util.scrollComment()">` el += icon('default:tocomment') el += `<span>${__('btn.comments')}</span>` el += `</a>` } } if (theme.edit_page?.enable && page.source) { const repo = theme.edit_page.repo const branch = theme.edit_page.branch || 'main' const basePath = theme.edit_page.base_path || '' const editUrl = `https://github.com/${repo}/edit/${branch}/${basePath}/${page.source}` el += `<a href="${editUrl}" target="_blank">` el += icon('default:edit') el += `<span>${theme.edit_page.edit_text || __(编辑本页)}</span>` el += `</a>` } el += `</div>` el += `</widget>`