summaryrefslogtreecommitdiff
path: root/layout/post.ejs
diff options
context:
space:
mode:
authorDoge <[email protected]>2021-05-15 17:35:35 +0800
committerDoge <[email protected]>2021-05-15 17:35:35 +0800
commit4ad7f73c7f04609a57fb322f652fbf4d6edd0241 (patch)
treeda6c7ecaf205c41cb519883c27109d35c7b65338 /layout/post.ejs
parent0090a12718400e9d3b230d85b93d54056eaede76 (diff)
downloadchromate-4ad7f73c7f04609a57fb322f652fbf4d6edd0241.tar.gz
chromate-4ad7f73c7f04609a57fb322f652fbf4d6edd0241.tar.bz2
chromate-4ad7f73c7f04609a57fb322f652fbf4d6edd0241.zip
Add chapters to web-player support
Diffstat (limited to 'layout/post.ejs')
-rw-r--r--layout/post.ejs29
1 files changed, 28 insertions, 1 deletions
diff --git a/layout/post.ejs b/layout/post.ejs
index 1e75de4..a9b1f8a 100644
--- a/layout/post.ejs
+++ b/layout/post.ejs
@@ -17,16 +17,43 @@
<%= page.title %>
</h2>
<% if (page.podcast) { %>
+ <script>let chapters = [];</script>
<div class="post-podcast-player"></div>
+ <% if (page.podcast.chapters) { %>
+ <%
+ let final = page.podcast.duration;
+ let timestamps = [];
+ let data = page.podcast.chapters;
+ let chapters = [];
+ (data).forEach((chapter) => {
+ timestamps.push(chapter[1]);
+ });
+ timestamps.push(final);
+ for (let index = 0; index < timestamps.length - 1; index++) {
+ let start = timestamps[index];
+ let end = timestamps[index + 1];
+ chapters.push({
+ title: data[index][0],
+ startTime: start, endTime: end
+ });
+ };
+ %>
+ <script>
+ chapters = JSON.parse('<%- JSON.stringify(chapters) %>');
+ </script>
+ <% } %>
<script>
window.addEventListener("load", () => {
+ if (chapters !== [])
+ Shikwasa.use(Chapter);
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 %>"
+ src: "<%= page.podcast.media.url %>",
+ chapters: chapters
},
fixed: {
type: "auto",