Skip to content

Commit

Permalink
feat(front-matter): add home_cover and post_cover settings
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed Sep 20, 2023
1 parent d97aa97 commit 10abbe2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
14 changes: 9 additions & 5 deletions layout/article-content.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

<div class="article-content-container border-box">

<% if (page?.cover) { %>
<div class="article-content-top border-box">
<% if (page?.post_cover || page?.home_cover) { %>
<div class="article-content-top border-box"
style="height: <%= page?.post_cover_height ? page?.post_cover_height + 'px' : '13.8rem' %>"
>
<div class="cover-article-title">
<%= page.title %>
</div>
<img class="post-cover" src="<%= page.cover %>" alt="<%= page.title %>">
<img class="post-cover" src="<%= page.post_cover || page?.home_cover %>"
onerror="this.style.display='none'"
>
</div>
<% } %>
<div class="article-content-bottom border-box<%= page?.cover ? ' has-cover' : '' %>">
<% if (!page?.cover) { %>
<div class="article-content-bottom border-box<%= (page?.post_cover || page?.home_cover) ? ' has-cover' : '' %>">
<% if (!page?.post_cover && !page?.home_cover) { %>
<div class="article-title">
<%= page.title %>
</div>
Expand Down
8 changes: 5 additions & 3 deletions layout/home-content.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
<% page.posts.forEach(post => { %>
<li class="home-article-item">
<% if (post?.cover) { %>
<% if (post?.home_cover) { %>
<div class="home-article-item-top border-box"
style="height: <%= post?.cover_height ? post?.cover_height + 'px' : '10rem' %>"
style="height: <%= post?.home_cover_height ? post?.home_cover_height + 'px' : '10rem' %>"
>
<% if (post.sticky) { %>
<div class="post-sticky-box cover">
<i class="fas fa-thumbtack"></i><span class="sticky-name">&nbsp;<%- __('top') %></span>
</div>
<% } %>
<img class="cover-img" src="<%= post.cover %>" alt="<%= post.title %>">
<img class="home-cover" src="<%= post.home_cover %>"
onerror="this.style.display='none'"
>
</div>
<% } %>
Expand Down
1 change: 0 additions & 1 deletion source/css/layout/article-content.styl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ $spacer-padding = 2rem
display flex
align-items flex-end
width 100%
height 13.8rem
padding-top $spacer-padding
padding-right $spacer-padding
overflow hidden
Expand Down
2 changes: 1 addition & 1 deletion source/css/layout/home-content.styl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
height 6rem
}

.cover-img {
.home-cover {
width 100%
height 100%
object-fit cover
Expand Down

0 comments on commit 10abbe2

Please sign in to comment.