Fix excerpt-less posts

This commit is contained in:
Shadowfacts 2022-04-07 22:49:37 -04:00
parent ecad667aed
commit d239a7eb5d
2 changed files with 9 additions and 5 deletions

View File

@ -37,7 +37,9 @@ async function generatePostFromFile(postPath: string, additionalMetadata: object
if (!(<PostMetadata>page.metadata).excerpt) {
const parts = page.text.split("<!-- excerpt-end -->");
(<PostMetadata>page.metadata).excerpt = parts[0];
if (parts.length > 1) {
(<PostMetadata>page.metadata).excerpt = parts[0];
}
}
return page;

View File

@ -10,9 +10,11 @@
</h2>
<%- include("article-meta.html.ejs", { metadata: post.metadata }) %>
<div class="article-content" itemprop="description">
<%- post.metadata.excerpt %>
<%- post.metadata.excerpt ?? post.text %>
</div>
<p class="read-more-link">
<a href="<%= post.metadata.permalink%>">Read more...</a>
</p>
<% if (post.metadata.excerpt) { %>
<p class="read-more-link">
<a href="<%= post.metadata.permalink%>">Read more...</a>
</p>
<% } %>
</article>