Files
RSSHub/lib/routes/chikubi/category.ts
T
Tsuyumi acdbd11e93 feat(route/chikubi): refactor URL fetching and add new routes (#16758)
* refactor(route/chikubi): switch to native /feed for article URL fetching

* feat: add new routes

* refactor: remove decodeURIComponent

* fix: Handle unescaped characters in tag URLs

* chore: use '@/utils/rss-parser' instead of 'rss-parser'

* chore: update description

* feat(utils): add getPostById and getPostsByIdList for REST API content fetching

* refactor(search): use getPostsByIdList instead of processItems

* fix: Handle unescaped characters

* refactor: Separate index and navigation

* feat: optimize post fetching by id and add category & tag functions

* refactor: use api to get posts for tags and categories

* chore: directly use url

* fix: use API to fetch 'best'

* fix: destructure post object in map function

* feat: optimize getPosts function for reusability

* refactor: remove wrapper functions for getBySlug and getPostsBy
2024-09-26 01:14:26 +08:00

42 lines
1.1 KiB
TypeScript

import { Route, Data } from '@/types';
import { getBySlug, getPostsBy } from './utils';
export const route: Route = {
path: '/category/:keyword',
categories: ['multimedia'],
example: '/chikubi/category/nipple-lesbian',
parameters: { keyword: 'Keyword' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Category',
maintainers: ['SnowAgar25'],
handler,
radar: [
{
title: 'Category',
source: ['chikubi.jp/category/:keyword'],
target: '/category/:keyword',
},
],
};
async function handler(ctx): Promise<Data> {
const baseUrl = 'https://chikubi.jp';
const { keyword } = ctx.req.param();
const { id, name } = await getBySlug('category', keyword);
const items = await getPostsBy('category', id);
return {
title: `Category: ${name} - chikubi.jp`,
link: `${baseUrl}/category/${keyword}`,
item: items,
};
}