mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat(route): add ui.dev newsletter archives: reactnewsletter.com and bytes.dev (#11499)
* feat(route): add ui.dev reactnewsletter.com and bytes.dev * fix(route): split reactnewsletter.com and bytes.dev into separate routes * fix(route): typo * fix: add missing radar and maintainer.js
This commit is contained in:
25
lib/v2/bytes/bytes.js
Normal file
25
lib/v2/bytes/bytes.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const currentURL = 'https://bytes.dev/archives';
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const resp = await got(currentURL);
|
||||
const $ = cheerio.load(resp.data);
|
||||
const text = $('script#__NEXT_DATA__').text();
|
||||
const json = JSON.parse(text);
|
||||
const posts = [json.props.pageProps.featuredPost].concat(json.props.pageProps.posts);
|
||||
const items = posts.map((item) => ({
|
||||
title: `Issue ${item.slug}`,
|
||||
pubDate: parseDate(item.date),
|
||||
description: item.title,
|
||||
link: `/archives/${item.slug}`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'bytes.dev',
|
||||
description: 'Your weekly dose of JS',
|
||||
link: currentURL,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user