summaryrefslogtreecommitdiff
path: root/scripts/meta.js
blob: 208358e93eb18c2807c2ebd736ae4f35f72fb903 (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
const ejs = require("ejs")

hexo.extend.tag.register('authors', function (_args) {
    let page = this;
    if (!(page.podcast && page.podcast.authors))
        return;
    return ejs.render(`
    <ul>
        <% (page.podcast.authors).forEach(function(author) { %>
            <li><%= author %></li>
        <% }); %>
    </ul>
    `, {page: page})
});

hexo.extend.tag.register('references', function (_args) {
    let page = this;
    if (!(page.podcast && page.podcast.references))
        return;
    return ejs.render(`
    <ul>
        <% (page.podcast.references).forEach(function(item) { %>
            <li><a href="<%= item[1] %>" rel="noopener"><%= item[0] %></a></li>
        <% }); %>
    </ul>
    `
    , {page: page});
});

hexo.extend.tag.register('timeline', function (_args) {
    let page = this;
    if (!(page.podcast && page.podcast.chapters))
        return;
    return ejs.render(`
    <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 %>" onclick="eval('player.seek(<%= timestamp %>)')">
                    <%= viewstr %>
                </a><%= title %>
            </li>
        <% }); %>
    </ul>
    `
    , {page: page});
});