mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
feat(route): Add route for njuferret.github.io (#15219)
* Add route for njuferret.github.io * Improve: use spread operator * Update lib/routes/njuferret/blog.ts
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/blog',
|
||||
categories: ['blog'],
|
||||
example: '/njuferret/blog',
|
||||
radar: [
|
||||
{
|
||||
source: ['njuferret.github.io'],
|
||||
},
|
||||
],
|
||||
name: 'Blogs',
|
||||
maintainers: ['tyl0622'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
const baseUrl = 'https://njuferret.github.io';
|
||||
const response = await ofetch(baseUrl);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('div.post-block')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a').first();
|
||||
return {
|
||||
title: a.text(),
|
||||
link: `${baseUrl}${a.attr('href')}`,
|
||||
pubDate: parseDate(item.find('time').attr('datetime')),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
title: 'njuferret - blog',
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'njuferret',
|
||||
url: 'njuferret.github.io',
|
||||
description: '',
|
||||
zh: {
|
||||
name: '有点博客',
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user