diff options
author | Doge <[email protected]> | 2021-05-28 11:07:09 +0800 |
---|---|---|
committer | Doge <[email protected]> | 2021-05-28 11:07:09 +0800 |
commit | 8509a71e550b0776e3af72230930665a01efb773 (patch) | |
tree | 6bb92041aa9a1227bd830c8a6f6b123250083e67 /layout | |
parent | 23ead76b3eafd3ab033aa7507b6620962a1be3ae (diff) | |
download | chromate-8509a71e550b0776e3af72230930665a01efb773.tar.gz chromate-8509a71e550b0776e3af72230930665a01efb773.tar.bz2 chromate-8509a71e550b0776e3af72230930665a01efb773.zip |
Fix invalid relative url in player and feed
Diffstat (limited to 'layout')
-rw-r--r-- | layout/post.ejs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/layout/post.ejs b/layout/post.ejs index 1419b70..9befb97 100644 --- a/layout/post.ejs +++ b/layout/post.ejs @@ -54,22 +54,30 @@ <% } %> <script> window.addEventListener("load", () => { - if (chapters !== []) - Shikwasa.use(Chapter); + if (chapters !== []) Shikwasa.use(Chapter); + + // Check for local audio media url + let url = "<%= page.podcast.media.url %>"; + if (!(url.startsWith("http://") || url.startsWith("https://"))) + url = "<%= full_url_for(path, {relative: false}) %>".replace("index.html", '') + url; + const player = new Shikwasa({ container: () => document.querySelector('.post-podcast-player'), - audio: { + audio: { title: "<%= page.title %>", artist: "<%= page.podcast.authors %>", cover: "<%= page.podcast.cover %>", - src: "<%= page.podcast.media.url %>", + duration: "<%= page.podcast.duration %>", + src: url, chapters: chapters }, fixed: { type: "auto", position: "bottom" }, - themeColor: "red" + themeColor: "red", + preload: "metadata", + autoplay: false }); window.player = player; }, false); |