rsshub
Version:
Make RSS Great Again!
43 lines (39 loc) • 1.06 kB
text/typescript
import { Route } from '@/types';
import got from '@/utils/got';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
import loadArticle from './article';
import { WPPost } from './types';
export const route: Route = {
path: '/',
categories: ['picture'],
example: '/4khd',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nsfw: true,
},
radar: [
{
source: ['www.4khd.com/'],
target: '',
},
],
name: 'Latest',
maintainers: ['AiraNadih'],
handler,
url: 'www.4khd.com/',
};
async function handler(ctx) {
const limit = Number.parseInt(ctx.req.query('limit')) || 20;
const { data: posts } = await got(`${SUB_URL}wp-json/wp/v2/posts?per_page=${limit}`);
return {
title: `${SUB_NAME_PREFIX} - Latest`,
link: SUB_URL,
item: posts.map((post) => loadArticle(post as WPPost)),
};
}