rsshub
Version:
Make RSS Great Again!
105 lines (101 loc) • 2.72 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs";
import "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import "./cache-SV6W5EPy.mjs";
import { t as getData } from "./utils-CNKBtxNj.mjs";
//#region lib/routes/aeon/type.ts
const ENDPOINT = "https://api.aeonmedia.co/graphql";
const LIST_BY_TYPE = `
query getAeonArticlesByType($type: [ArticleTypeEnum!], $sortField: ArticleSortEnum = published_at, $afterCursor: String, $tag: String) {
articles(
site: aeon
type: $type
status: [published]
tag: $tag
sort: {field: $sortField, order: desc}
after: $afterCursor
first: 12
) {
nodes {
slug
...aeonArticleCardFragment
}
}
}
fragment aeonArticleCardFragment on Article {
id
title
slug
type
standfirstLong
authors { name }
image { url }
primaryTopic { title }
section { slug }
}
`;
const route = {
path: "/:type",
categories: ["new-media"],
example: "/aeon/essays",
parameters: { type: {
description: "Type",
options: [{
value: "essays",
label: "Essays"
}, {
value: "videos",
label: "Videos"
}]
} },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["aeon.co/:type"] }],
name: "Types",
maintainers: ["emdoe"],
handler,
description: `Supported types: Essays and Videos.
Compared to the official one, the RSS feed generated by RSSHub not only has more fine-grained options, but also eliminates pull quotes, which can't be easily distinguished from other paragraphs by any RSS reader, but only disrupt the reading flow. This feed also provides users with a bio of the author at the top.`
};
async function handler(ctx) {
const type = ctx.req.param("type");
const capitalizedType = type.charAt(0).toUpperCase() + type.slice(1);
const url = `https://aeon.co/${type}`;
const items = await getData((await ofetch_default(ENDPOINT, {
method: "POST",
body: {
query: LIST_BY_TYPE,
variables: {
type: [type.slice(0, -1)],
sortField: "published_at"
},
operationName: "getAeonArticlesByType"
}
})).data.articles.nodes.map((node) => ({
title: node.title,
description: node.standfirstLong,
author: node.authors.map((author) => author.name).join(", "),
link: `https://aeon.co/${type}/${node.slug}`,
category: node.primaryTopic.title,
image: node.image.url,
type: node.type,
section: node.section.slug,
slug: node.slug
})));
return {
title: `AEON | ${capitalizedType}`,
link: url,
item: items
};
}
//#endregion
export { route };