UNPKG

rsshub

Version:
39 lines (38 loc) 1.58 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; //#region lib/routes/yinxiang/category.ts const route = { path: "/category/:id", categories: ["study"], example: "/yinxiang/category/28", parameters: { id: "分类 id,可在分类页 URL 中找到" }, name: "笔记分类", maintainers: ["nczitzk"], handler }; async function handler(ctx) { const { id } = ctx.req.param(); const apiUrl = `https://app.yinxiang.com/third/discovery/client/restful/public/category/page?notePageSize=20&lastBlogNoteGuid=&cateGoryId=${id}`; const response = await rofetch(apiUrl); const list = response.categoryNoteSnapshotReply.map((item) => ({ title: item.title, link: item.noteGuid, author: item.userNickname })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await rofetch(`https://app.yinxiang.com/third/discovery/client/restful/public/blog-note?noteGuid=${item.link}`); item.link = `https://www.yinxiang.com/everhub/note/${item.link}`; item.pubDate = parseDate(Number(detailResponse.blogNote.publishTime)); const description = detailResponse.blogNote.htmlContent; item.description = description.includes("<?xml") ? description.match(/<en-note>(.*)<\/en-note>/)[1] : description; return item; }))); return { title: `${response.categoryName} - 印象识堂`, link: `https://www.yinxiang.com/everhub/category/${id}`, item: items }; } //#endregion export { route };