UNPKG

rsshub

Version:
47 lines (45 loc) 1.62 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.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 };