summaryrefslogtreecommitdiff
path: root/layout/index.ejs
blob: 64db0daf34ec4118bb5e63e21859c8f172fd6ec3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<section class="posts">
    <% page.posts.each(function (post) { %>
        <article class="post">
            <!-- Post thumbnail with lazayload support -->
            <% if (post.thumbnail) { %> 
                <% if (theme.lazyload === true) { %>
                    <div class="post-thumbnail lazy" data-bg="<%= post.thumbnail %>"></div>
                <% } else { %>
                    <div class="post-thumbnail" style="background-image: url('<%= post.thumbnail %>');"></div>
                <% } %>
            <% } %>

            <!-- Post title and excerpt -->
            <h1 class="post-title">
                <a class="post-link" href="<%- url_for(post.path) %>">
                    <%= post.title %>
                </a>
            </h1>
            <% if (post.excerpt) { %>
                <div class="post-excerpt"><%- post.excerpt %></div>
            <% } else { %>
                <div class="post-content"><%- post.content %></div>
            <% } %>

            <!-- Post meta -->
            <div class="post-meta">
                <% if (post.podcast && theme.podcast) { %>
                    <%
                        const duration = post.podcast.duration;
                        const hour = Math.floor(duration / 3600);
                        const minute = Math.floor((duration / 60) % 60);
                        const second = Math.floor(duration % 60);
                        const viewstr = hour + ':' + String(minute).padStart(2, '0') + ':' + String(second).padStart(2, '0');
                    %>
                    <div class="post-duration"><%- viewstr %></div>
                <% } %>
                <div class="post-time">
                    <%- date(post.date, theme.timeformat) %> 
                </div>
                <% if (post.tags) { %> 
                    <div class="post-tags">
                        <% (post.tags).forEach(function(item) { %>
                            <span class="post-tag"><%= item.name %></span>
                        <% }); %>
                    </div>
                <% } %>
            </div>
        </article>
    <% }) %>

    <!-- Page navigation -->
    <% if (page.prev || page.next) { %>
        <div class="nav">
            <% if (page.prev) { %>
                <div class="nav-prev">
                    <a href="<%- url_for(page.prev_link) %>" class="nav-link">
                        <span class="nav-label">
                            Prev
                            <i class="fa fa-chevron-left"></i>
                        </span>
                    </a>
                </div>
            <% } %>
            <% if (page.next) { %>
                <div class="nav-next">  
                    <a href="<%- url_for(page.next_link) %>" class="nav-link">
                        <span class="nav-label">
                            Next
                            <i class="fa fa-chevron-right"></i>
                        </span>
                    </a>
                </div>
            <% } %>
        </div>
    <% } %>
</section>