diff options
author | Doge <[email protected]> | 2021-05-13 18:53:19 +0800 |
---|---|---|
committer | Doge <[email protected]> | 2021-05-13 18:53:19 +0800 |
commit | 5e2ae7733ca351ae57fc4fd756ec03f4bc0fc672 (patch) | |
tree | dd2960c2caadf4cfaea4f7a6b5513adfc5bcf2c7 /scripts | |
parent | 7dcd9aea80061bdcdbafb172e478213a962c2f6c (diff) | |
download | chromate-5e2ae7733ca351ae57fc4fd756ec03f4bc0fc672.tar.gz chromate-5e2ae7733ca351ae57fc4fd756ec03f4bc0fc672.tar.bz2 chromate-5e2ae7733ca351ae57fc4fd756ec03f4bc0fc672.zip |
Add rss auto discovery and fix some bugs with rss
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/feed.js | 7 | ||||
-rw-r--r-- | scripts/meta.js | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/scripts/feed.js b/scripts/feed.js index 6ea931e..a28cea2 100644 --- a/scripts/feed.js +++ b/scripts/feed.js @@ -1,7 +1,5 @@ 'use strict'; -const podcast = require("podcast"); - hexo.extend.generator.register("feed", (locals) => { // Load config @@ -11,6 +9,8 @@ hexo.extend.generator.register("feed", (locals) => { const hstrip = hexo.extend.helper.get("strip_html").bind(hexo); if (!theme.rss || !theme.rss.enable) return; + const podcast = require("podcast"); + // Render for site config const feed = new podcast({ title: config.title, @@ -33,9 +33,10 @@ hexo.extend.generator.register("feed", (locals) => { // Rendering for podcasts locals.posts.sort('date', -1).each(function (post) { if (!post.podcast) return; + let description = post.content.replaceAll(/onclick=".*?"/gi, ''); feed.addItem({ title: post.title, - description: post.content, + description: description.replace(/>\s+</g, '><', ''), url: config.url + urler(post.path), guid: config.url + urler(post.path), author: post.podcast.authors.join(', '), diff --git a/scripts/meta.js b/scripts/meta.js index 9b4a779..046e939 100644 --- a/scripts/meta.js +++ b/scripts/meta.js @@ -31,6 +31,7 @@ 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) { %> @@ -42,9 +43,13 @@ hexo.extend.tag.register('timeline', function (_args) { 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> + <li class="is-family-monospace"> + <a href="<%= urler(page.path) %>#t=<%= viewstr %>" onclick="eval('player.seek(<%= timestamp %>)')"> + <%= viewstr %> + </a><%= title %> + </li> <% }); %> </ul> ` - , {page: page}); + , {page: page, urler: urler}); }) |