From ef94bcde8eac690dfb34dfebc49c622ee2047607 Mon Sep 17 00:00:00 2001 From: Chenxing Luo Date: Fri, 8 Apr 2022 11:48:28 -0400 Subject: [PATCH] feat(route): add two blogs: Stratechery & Miris Whispers (#9496) * Add two blogs * fix(utils): add parseDate timezone common-config * Update lib/v2/stratechery/index.js Co-authored-by: Tony * Update docs/blog.md Co-authored-by: Tony * Update docs/en/blog.md Co-authored-by: Tony * Update lib/v2/miris/blog.js --- docs/blog.md | 8 ++++++++ docs/en/blog.md | 8 ++++++++ lib/utils/common-config.js | 4 ++++ lib/v2/miris/blog.js | 19 +++++++++++++++++++ lib/v2/miris/radar.js | 11 +++++++++++ lib/v2/miris/router.js | 3 +++ lib/v2/stratechery/index.js | 20 ++++++++++++++++++++ lib/v2/stratechery/radar.js | 11 +++++++++++ lib/v2/stratechery/router.js | 3 +++ 9 files changed, 87 insertions(+) create mode 100644 lib/v2/miris/blog.js create mode 100644 lib/v2/miris/radar.js create mode 100644 lib/v2/miris/router.js create mode 100644 lib/v2/stratechery/index.js create mode 100644 lib/v2/stratechery/radar.js create mode 100644 lib/v2/stratechery/router.js diff --git a/docs/blog.md b/docs/blog.md index 8cb069d66..c01b8b627 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -80,6 +80,10 @@ pageClass: routes +## Miris Whispers + + + ## Paul Graham 博客 通过提取文章全文,提供比官方源更佳的阅读体验。 @@ -106,6 +110,10 @@ pageClass: routes ::: +## Stratechery by Ben Thompson + + + ## Whoscall ### 最新文章 diff --git a/docs/en/blog.md b/docs/en/blog.md index bce6314e8..75cf2a0db 100644 --- a/docs/en/blog.md +++ b/docs/en/blog.md @@ -40,6 +40,10 @@ pageClass: routes +## Miris Whispers + + + ## Paul Graham ### Essays @@ -66,6 +70,10 @@ Limit the number of entries to be retrieved by adding `?limit=x` to the end of t +## Stratechery by Ben Thompson + + + ## WordPress diff --git a/lib/utils/common-config.js b/lib/utils/common-config.js index 5ca9df32d..e9896132d 100644 --- a/lib/utils/common-config.js +++ b/lib/utils/common-config.js @@ -3,6 +3,10 @@ const got = require('@/utils/got'); const iconv = require('iconv-lite'); // eslint-disable-next-line no-unused-vars const date = require('@/utils/date'); +// eslint-disable-next-line no-unused-vars +const { parseDate } = require('@/utils/parse-date'); +// eslint-disable-next-line no-unused-vars +const timezone = require('@/utils/timezone'); function transElemText($, prop) { const regex = new RegExp(/\$\((.*)\)/g); diff --git a/lib/v2/miris/blog.js b/lib/v2/miris/blog.js new file mode 100644 index 000000000..e4fec8456 --- /dev/null +++ b/lib/v2/miris/blog.js @@ -0,0 +1,19 @@ +const buildData = require('@/utils/common-config'); + +module.exports = async (ctx) => { + const link = 'https://blog.miris.design/'; + + ctx.state.data = await buildData({ + link, + url: link, + title: 'Miris Whisper', + author: 'Miris', + description: 'Esoteric technical and sometimes personal stuff...', + item: { + item: 'ul > li', + title: `$('li > a').contents().filter(function () { return this.type === 'text' }).text()`, + link: `$('li > a').attr('href')`, + pubDate: `parseDate($('li > a > .date').text().slice(1, 11))`, + }, + }); +}; diff --git a/lib/v2/miris/radar.js b/lib/v2/miris/radar.js new file mode 100644 index 000000000..0b66aec85 --- /dev/null +++ b/lib/v2/miris/radar.js @@ -0,0 +1,11 @@ +module.exports = { + 'miris.design': { + _name: 'Miris', + blog: [ + { + title: 'Miris Whispers', + docs: 'https://docs.rsshub.app/en/blog.html#miris-design', + }, + ], + }, +}; diff --git a/lib/v2/miris/router.js b/lib/v2/miris/router.js new file mode 100644 index 000000000..be98531b9 --- /dev/null +++ b/lib/v2/miris/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/blog', require('./blog')); +}; diff --git a/lib/v2/stratechery/index.js b/lib/v2/stratechery/index.js new file mode 100644 index 000000000..8b26aab02 --- /dev/null +++ b/lib/v2/stratechery/index.js @@ -0,0 +1,20 @@ +const buildData = require('@/utils/common-config'); + +module.exports = async (ctx) => { + const link = 'https://stratechery.com/'; + + ctx.state.data = await buildData({ + link, + url: link, + title: 'Stratechery by Ben Thompson', + author: 'Ben Thompson', + description: 'Stratechery provides analysis of the strategy and business side of technology and media, and the impact of technology on society. ', + item: { + item: 'article', + title: `$('article > header > h1 > a').text()`, + link: `$('article > header > h1 > a').attr('href')`, + pubDate: `parseDate($('article .entry-date').attr('datetime'))`, + description: `$('article > .entry-content').html().replace(/%/g, '%')`, + }, + }); +}; diff --git a/lib/v2/stratechery/radar.js b/lib/v2/stratechery/radar.js new file mode 100644 index 000000000..7fbea66cc --- /dev/null +++ b/lib/v2/stratechery/radar.js @@ -0,0 +1,11 @@ +module.exports = { + 'miris.design': { + _name: 'Stratechery by Ben Thompson', + blog: [ + { + title: 'Articles', + docs: 'https://docs.rsshub.app/en/blog.html#stratechery-by-ben-thompson', + }, + ], + }, +}; diff --git a/lib/v2/stratechery/router.js b/lib/v2/stratechery/router.js new file mode 100644 index 000000000..cf5796bea --- /dev/null +++ b/lib/v2/stratechery/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('.')); +};