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:
parent
df4019250a
commit
292471ec23
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'imhcg的信息站',
|
||||
url: 'infos.imhcg.cn',
|
||||
description: '包含多种技术和新闻信息的网站',
|
||||
};
|
||||
Loading…
Reference in New Issue