rsshub
Version:
Make RSS Great Again!
66 lines (63 loc) • 2.41 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import { t as logger_default } from "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
//#region lib/routes/foodtalks/namespace.ts
const namespace = {
name: "FoodTalks全球食品资讯网",
url: "www.foodtalks.cn",
categories: ["new-media"],
lang: "zh-CN",
description: "FoodTalks全球食品资讯网是一个提供食品饮料行业新闻、资讯、分析和商业资源的领先在线平台。它涵盖行业趋势、市场动态、产品创新、投融资信息以及企业新闻,连接行业内的专业人士、企业和消费者。"
};
//#endregion
//#region lib/routes/foodtalks/index.ts
const route = {
path: "/",
categories: namespace.categories,
example: "/foodtalks",
radar: [{ source: ["www.foodtalks.cn"] }],
name: "FoodTalks global food information network",
maintainers: ["Geraldxm"],
handler,
url: "www.foodtalks.cn"
};
function processItems(list, fullTextApi) {
return Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
try {
item.description = (await ofetch_default(fullTextApi.replace("{id}", item.id), { headers: {
referrer: "https://www.foodtalks.cn/",
method: "GET"
} })).data.content;
return item;
} catch (error) {
logger_default.error(`Error fetching full text for ${item.link}:`, error);
return item;
}
})));
}
async function handler(ctx) {
const items = await processItems((await ofetch_default(`https://api-we.foodtalks.cn/news/news/page?current=1&size=${ctx.req.query("limit") || 15}&isLatest=1&language=ZH`, { headers: {
referrer: "https://www.foodtalks.cn/",
method: "GET"
} })).data.records.map((item) => ({
title: item.title,
pubDate: new Date(item.publishTime),
link: `https://www.foodtalks.cn/news/${item.id}`,
category: item.parentTagCode === "category" ? item.tagCode : item.parentTagCode,
author: item.author === null ? item.sourceName : item.author,
id: item.id,
image: item.coverImg
})), "https://api-we.foodtalks.cn/news/news/{id}?language=ZH");
return {
title: namespace.name,
description: namespace.description,
link: "https://" + namespace.url,
item: items,
image: "https://www.foodtalks.cn/static/img/news-site-logo.7aaa5463.svg"
};
}
//#endregion
export { route };