From 04ecc3472802ec02f943a63683d3e311bfc19613 Mon Sep 17 00:00:00 2001
From: Doge <guiqiqi187@gmail.com>
Date: Sat, 8 May 2021 01:21:15 +0800
Subject: Add podcast player support

Thanks to Shikwasa :+1:
---
 layout/post.ejs | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

(limited to 'layout/post.ejs')

diff --git a/layout/post.ejs b/layout/post.ejs
index 0de6e5a..d83d694 100644
--- a/layout/post.ejs
+++ b/layout/post.ejs
@@ -2,10 +2,31 @@
     <!-- Post thumbnail with lazayload support -->
     <div class="post-thumbnail" style="background-image: url('<%= page.thumbnail %>');"></div>
 
+    <!-- Podcast Player using Shikwasa -->
+    <% 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.author %>",
+                        cover: "<%= page.podcast.thumbnail %>",
+                        src: "<%= page.podcast.media %>"
+                    },
+                    fixed: {
+                        type: "static"
+                    }
+                });
+            }, false);
+        </script>
+    <% } %> 
+
     <!-- Post title and content -->
     <div class="post-meta">
         <div class="post-time">
-            <%- date(page.date, "MMM, D YYYY" ) %>
+            <%- date(page.date, "MMM, D YYYY") %>
         </div>
     </div>
     <h1 class="post-title"><%= page.title %></h1>
-- 
cgit v1.2.3