UNPKG

rsshub

Version:
52 lines (51 loc) 1.82 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; //#region lib/routes/im2maker/index.ts const route = { path: "/:channel?", categories: ["new-media"], example: "/im2maker", parameters: { channel: "默认不填为 最新文章 ,频道如下" }, description: `| 最新文章 | 行业快讯 | 行业观察 | 镁客请讲 | 硬科技 100 人 | 投融界 | 万象 | | -------- | -------- | -------- | -------- | ------------- | -------- | ---------- | | | fresh | industry | talk | intech | investor | everything |`, name: "频道", maintainers: ["jin1218scu"], handler }; async function handler(ctx) { const baseUrl = "https://www.im2maker.com"; const channel = ctx.req.param("channel")?.toLowerCase(); let title = "最新文章"; let link = baseUrl; const query = { _embed: "", per_page: ctx.req.query("limit") === "10" ? void 0 : ctx.req.query("limit") }; if (channel) { const category = await cache_default.tryGet(`im2maker:category:${channel}`, async () => { return (await rofetch(`${baseUrl}/wp-json/wp/v2/categories`, { query: { slug: channel } }))[0]; }); title = category.name; link = category.link; query.categories = category.id; } const items = (await rofetch(`${baseUrl}/wp-json/wp/v2/posts`, { query })).map((post) => ({ title: post.title.rendered, link: post.link, guid: post.guid.rendered, description: post.content.rendered, pubDate: parseDate(post.date_gmt), author: post._embedded?.author?.[0]?.name, category: post._embedded?.["wp:term"]?.flat().map((term) => term.name) })); return { title: `镁客网 ${title}`, link, description: "镁客网", item: items }; } //#endregion export { route };