summaryrefslogtreecommitdiff
path: root/layout/post.ejs
blob: 699757427281d4168d15f9838a18e4310d6d2e3c (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<div class="columns">
    <div class="column is-8 is-offset-2">
        <div class="card">
            <% if (page.thumbnail) { %>
                <div class="card-iamge">
                    <figure class="image is-16by9">
                        <% if (theme.lazyload === true) { %>
                            <img class="lazy" data-src="<%= page.thumbnail %>" />
                        <% } else { %>
                            <img src="<%= page.thumbnail %>" />
                        <% } %>
                    </figure>
                </div>
            <% } %>
            <div class="card-content post-card">
                <h2 class="title has-text-centered">
                    <%= page.title %>
                </h2>
                <% if (page.podcast) { %>
                    <div class="post-podcast-player"></div>
                    <script>
                        window.addEventListener("load", () => {
                            const player = new Shikwasa({
                                container: () => document.querySelector('.post-podcast-player'),
                                audio: {
                                    title: "<%= page.title %>",
                                    artist: "<%= page.podcast.authors %>",
                                    cover: "<%= page.podcast.cover %>",
                                    src: "<%= page.podcast.media.url %>"
                                },
                                fixed: {
                                    type: "auto",
                                    position: "bottom"
                                },
                                themeColor: "red"
                            });
                        }, false);
                    </script>
                <% } %>
                <section class="content is-size-6">

                    <%- page.content %>

                    <!-- Add podcast authors -->
                    
                    <% if (page.podcast && page.podcast.authors) { %>
                        <h3><%= __('authors') %>: </h3>
                        <ul>
                            <% (page.podcast.authors).forEach(function(author) { %>
                                <li><%= author %></li>
                            <% }); %> 
                        </ul>
                    <% } %>  
                    
                    <!-- Add podcast chapters -->
                    <% if (page.podcast && page.podcast.chapters) { %>
                        <h3><%= __('timeline') %>: </h3>
                        <ul>
                            <% (page.podcast.chapters).forEach(function(item) { %>
                                <%
                                    const title = item[0];
                                    const timestamp = item[1];
                                    const hour = Math.floor(timestamp / 3600);
                                    const minute = Math.floor((timestamp / 60) % 60);
                                    const second = Math.floor(timestamp % 60);
                                    const viewstr = String(hour).padStart(2, '0') + ':' + String(minute).padStart(2, '0') + ':' + String(second).padStart(2, '0');
                                %> 
                                <li class="is-family-monospace"><a href="#t=<%= viewstr %>"><%= viewstr %></a> <%= title %></li>
                            <% }); %>
                        </ul>
                    <% } %>

                    <!-- Add podcast references -->
                    <% if (page.podcast && page.podcast.references) { %>
                        <h3><%= __('references') %>: </h3>
                        <ul>
                            <% (page.podcast.references).forEach(function(item) { %>
                                <li><a href="<%= item[1] %>" rel="noopener"><%= item[0] %></a></li>
                            <% }); %>
                        </ul>
                    <% } %>

                </section>
                <div class="level">
                    <div class="level-left">
                        <div class="level-item">
                            <% if (page.tags) { %>
                                <div class="tags">
                                    <% (page.tags).forEach(function(item) { %>
                                        <span class="tag"># <%= item.name %></span>
                                        <% }); %>
                                </div>
                            <% } %>
                        </div>
                    </div>
                </div>                
            </div>
        </div>
    </div>
</div>