rsshub
Version:
Make RSS Great Again!
46 lines (44 loc) • 1.58 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import { t as config } from "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
//#region lib/routes/atptour/news.ts
const route = {
path: "/news/:lang?",
categories: ["other"],
example: "/atptour/news/en",
parameters: { lang: "en or es." },
radar: [{ source: ["atptour.com"] }],
name: "News",
maintainers: ["LM1207"],
handler
};
async function handler(ctx) {
const baseUrl = "https://www.atptour.com";
const favIcon = `${baseUrl}/assets/atptour/assets/favicon.ico`;
const { lang = "en" } = ctx.req.param();
const { data } = await got_default(`${baseUrl}/${lang}/-/tour/news/latest-filtered-results/0/${ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 15}`, { headers: { "user-agent": config.trueUA } });
return {
title: lang === "en" ? "News" : "Noticias",
link: `${baseUrl}/${lang}/news/news-filter-results`,
description: lang === "en" ? "News from the official site of men's professional tennis." : "Noticias del sitio oficial del tenis profesional masculino.",
language: lang,
icon: favIcon,
logo: favIcon,
author: "ATP",
item: data.content.map((item) => ({
title: item.title,
link: baseUrl + item.url,
description: item.description,
author: item.byline,
category: item.category,
pubDate: parseDate(item.authoredDate),
image: baseUrl + item.image
}))
};
}
//#endregion
export { route };