Files
RSSHub/lib/v2/aeon/category.js
Enoch Ma 051a3efcbb fix(route): aeon - support for other categories (#12614)
* aeon: hotfix & migrate to v2

* rewrite & focus on essays

* fix banner

* better support for aeon

* update the doc

* credits before content

* using templates & fix doc
2023-06-05 23:50:00 +08:00

28 lines
927 B
JavaScript

const cheerio = require('cheerio');
const got = require('@/utils/got');
const { getData } = require('./utils');
module.exports = async (ctx) => {
const url = `https://aeon.co/${ctx.params.category}`;
const { data: response } = await got(url);
const $ = cheerio.load(response);
const data = JSON.parse($('script#__NEXT_DATA__').text());
const list = data.props.pageProps.section.articles.edges.map((item) => ({
title: item.node.title,
author: item.node.authors.map((author) => author.displayName).join(', '),
link: `https://aeon.co/${item.node.type.toLowerCase()}s/${item.node.slug}`,
pubDate: item.node.createdAt,
}));
const items = await getData(ctx, list);
ctx.state.data = {
title: `AEON | ${data.props.pageProps.section.title}`,
link: url,
description: data.props.pageProps.section.metaDescription,
item: items,
};
};