Skip to content

Commit

Permalink
Merge pull request #21 from rikumi/contrib
Browse files Browse the repository at this point in the history
Fix postlist featuredImage absolute url
  • Loading branch information
sumimakito committed Nov 24, 2019
2 parents 4d53810 + 4e0b47a commit 1da6172
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion layout/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ config.__isIndex = true
<% include _include/side_nav.ejs %>
<% include _include/extra_nav.ejs %>

<%
function getFeaturedImage(item) {
var featuredImage = item.featured_image;
if (!featuredImage) return '';
if (featuredImage.startsWith("http://") || featuredImage.startsWith("https://")) return featuredImage;
return config.root + item.path + featuredImage;
}
%>

<div ref="streamContainer" class="stream-container">
<div class="post-list-container post-list-container-no-background">
<% page.posts.each(function (item) { %>
Expand All @@ -31,7 +40,7 @@ config.__isIndex = true
<% if(item.featured_image){ %>
<div class="post-item-image-wrapper">
<div class="post-item-image"
style="background-image: url('<%= config.root + item.path + item.featured_image %>')"></div>
style="background-image: url('<%= getFeaturedImage(item) %>')"></div>
</div>
<% } %>
</div>
Expand Down

0 comments on commit 1da6172

Please sign in to comment.