feat(route): add route for Engineering blogs (#16529)

* 制作imhcg的路由

* 遵循路由规范

* Update lib/routes/imhcg/blog.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/imhcg/blog.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* 修改imhcg的namespace,使其与route name不同

* Update lib/routes/imhcg/namespace.ts

---------
This commit is contained in:
zihao 2024-08-26 00:33:53 +08:00 committed by GitHub
parent df4019250a
commit 292471ec23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 0 deletions

47
lib/routes/imhcg/blog.ts Normal file
View File

@ -0,0 +1,47 @@
import { Route, ViewType } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
export const route: Route = {
path: '/',
categories: ['blog'],
view: ViewType.Notifications,
example: '/',
parameters: {},
radar: [
{
source: ['infos.imhcg.cn'],
},
],
name: 'Engineering blogs',
maintainers: ['ZiHao256'],
handler,
url: 'https://infos.imhcg.cn/',
};
async function handler() {
const response = await ofetch('https://infos.imhcg.cn/');
const $ = load(response);
const items = $('li')
.toArray()
.map((item) => {
const title = $(item).find('a.title').text();
const link = $(item).find('a.title').attr('href');
const author = $(item).find('p.author').text();
const time = $(item).find('p.time').text();
const description = $(item).find('p.text').text();
return {
title,
link,
author,
time,
description,
};
});
return {
title: `Engineering Blogs`,
link: 'https://infos.imhcg.cn/',
item: items,
};
}

View File

@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'imhcg的信息站',
url: 'infos.imhcg.cn',
description: '包含多种技术和新闻信息的网站',
};