diff options
| -rw-r--r-- | layout/post.ejs | 18 | ||||
| -rw-r--r-- | scripts/feed.js | 7 | ||||
| -rw-r--r-- | scripts/meta.js | 3 | 
3 files changed, 21 insertions, 7 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); diff --git a/scripts/feed.js b/scripts/feed.js index 87e672b..f1a2fc9 100644 --- a/scripts/feed.js +++ b/scripts/feed.js @@ -6,6 +6,7 @@ hexo.extend.generator.register("feed", (locals) => {      const config = hexo.config;      const theme = hexo.theme.config;      const urler = hexo.extend.helper.get("url_for").bind(hexo); +    const fullurl = hexo.extend.helper.get("full_url_for").bind(hexo);      const hstrip = hexo.extend.helper.get("strip_html").bind(hexo);      if (!theme.rss || !theme.rss.enable) return; @@ -54,6 +55,12 @@ hexo.extend.generator.register("feed", (locals) => {              .replace(/id=".*?"/gi, '').replace(/rel=".*?"/gi, '')              .replace(/title=".*?"/gi, '').replace(/\n/g, "")              .replace(/\s+/g, ' ').trim(); + +        // Check local media url +        let url = post.podcast.media.url; +        if (!(url.startsWith("http://") || url.startsWith("https://"))) +            url = fullurl(post.path, {relative: false}).replace("index.html", '') + url; +          feed.addItem({              title: post.title,              description: description, diff --git a/scripts/meta.js b/scripts/meta.js index 23311a6..208358e 100644 --- a/scripts/meta.js +++ b/scripts/meta.js @@ -31,7 +31,6 @@ hexo.extend.tag.register('timeline', function (_args) {      let page = this;      if (!(page.podcast && page.podcast.chapters))          return; -    const urler = hexo.extend.helper.get("full_url_for").bind(hexo);      return ejs.render(`      <ul>          <% (page.podcast.chapters).forEach(function(item) { %> @@ -51,5 +50,5 @@ hexo.extend.tag.register('timeline', function (_args) {          <% }); %>      </ul>      ` -    , {page: page, urler: urler}); +    , {page: page});  }); | 
