From 41b3e4407d90fbe64c0bc927a9cca542c724e19f Mon Sep 17 00:00:00 2001 From: Jinkin Date: Thu, 25 Jul 2024 17:56:55 +0800 Subject: [PATCH] feat(route): chlinlearn daily bolg (#16216) * feat: add new site chlinlearn new blogs * Initial commit * Update lib/routes/chlinlearn/daily-blog.ts Co-authored-by: Tony * Update lib/routes/chlinlearn/namespcae.ts Co-authored-by: Tony * Update namespcae.ts * Update lib/routes/chlinlearn/namespcae.ts --------- --- lib/routes/chlinlearn/daily-blog.ts | 48 +++++++++++++++++++++++++++++ lib/routes/chlinlearn/namespcae.ts | 6 ++++ 2 files changed, 54 insertions(+) create mode 100644 lib/routes/chlinlearn/daily-blog.ts create mode 100644 lib/routes/chlinlearn/namespcae.ts diff --git a/lib/routes/chlinlearn/daily-blog.ts b/lib/routes/chlinlearn/daily-blog.ts new file mode 100644 index 00000000000000..7d1e56140db537 --- /dev/null +++ b/lib/routes/chlinlearn/daily-blog.ts @@ -0,0 +1,48 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; // 统一使用的请求库 +import { parseDate } from '@/utils/parse-date'; // 解析日期的工具函数 +import timezone from '@/utils/timezone'; + +export const route: Route = { + path: '/daily-blog', + name: '值得一读技术博客', + maintainers: ['huyyi'], + categories: ['programming'], + example: '/chlinlearn/daily-blog', + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['daily-blog.chlinlearn.top/blogs/*'], + target: '/chlinlearn/daily-blog', + }, + ], + handler: async () => { + const data = await ofetch('https://daily-blog.chlinlearn.top/api/daily-blog/getBlogs/new?type=new&pageNum=1&pageSize=20', { + headers: { + Referer: 'https://daily-blog.chlinlearn.top/blogs/1', + }, + }); + const items = data.rows.map((item) => ({ + title: item.title, + link: item.url, + author: item.author, + img: item.icon, + pubDate: timezone(parseDate(item.publishTime), +8), + })); + return { + // 源标题 + title: '值得一读技术博客', + // 源链接 + link: 'https://daily-blog.chlinlearn.top/blogs/1', + // 源文章 + item: items, + }; + }, +}; diff --git a/lib/routes/chlinlearn/namespcae.ts b/lib/routes/chlinlearn/namespcae.ts new file mode 100644 index 00000000000000..bfca8e01eee26c --- /dev/null +++ b/lib/routes/chlinlearn/namespcae.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'chlinlearn的技术博客', + url: 'daily-blog.chlinlearn.top', +};