chore: push type changes to docs

This commit is contained in:
Tony 2024-03-24 13:14:41 +08:00
parent 63adaee7f2
commit e8b0d7d262
7 changed files with 44 additions and 15 deletions

View File

@ -57,6 +57,8 @@ jobs:
run: |
cp -r ./assets/build/docs/en/* ./rsshub-docs/src/routes
cp -r ./assets/build/docs/zh/* ./rsshub-docs/src/zh/routes
cp ./lib/types.ts ./rsshub-docs/.vitepress/theme/types.ts
cp ./scripts/workflow/data.ts ./rsshub-docs/.vitepress/config/data.ts
- name: Commit docs
run: |
cd rsshub-docs

View File

@ -31,9 +31,9 @@ export const route: Route = {
| ps4 | sgame | 3ds | psv | jiaocheng | ps3yx | zhuji.md | zhangji.psp | pcgame | zhangji | zhuji | ps4.psjc | ps41.ps4pkg | nsaita.cundang | nsaita.pojie | nsaita.buding | nsaita.zhutie | nsaita.zhuti |`,
};
async function handler(ctx?: Context): Promise<Data> {
const category = (ctx!.req.param('category') ?? 'sgame').replaceAll('.', '/');
const tab = ctx?.req.param('tab') ?? 'all';
async function handler(ctx: Context): Promise<Data> {
const category = (ctx.req.param('category') ?? 'sgame').replaceAll('.', '/');
const tab = ctx.req.param('tab') ?? 'all';
const currentUrl = `https://www.2023game.com/${category}/`;

View File

@ -1,6 +1,6 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import cherrio from 'cheerio';
import * as cheerio from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import puppeteer from '@/utils/puppeteer';
@ -43,7 +43,7 @@ async function handler() {
const res = await page.evaluate(() => document.documentElement.innerHTML);
await page.close();
const $ = cherrio.load(res);
const $ = cheerio.load(res);
const items = $('div h3 a')
.toArray()
@ -67,7 +67,7 @@ async function handler() {
waitUntil: 'domcontentloaded',
});
const res = await page.evaluate(() => document.documentElement.innerHTML);
const $ = cherrio.load(res);
const $ = cheerio.load(res);
await page.close();
item.description = $('div.article__body').html();

View File

@ -1,6 +1,6 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import cherrio from 'cheerio';
import * as cheerio from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@ -34,7 +34,7 @@ async function handler() {
const url = `${homepage}/f/article/articleList?pageNo=1&pageSize=15&createTimeSort=DESC`;
const response = await got(url);
const $ = cherrio.load(response.data);
const $ = cheerio.load(response.data);
const articles = $('.aw-item').toArray();
const items = await Promise.all(
@ -45,7 +45,7 @@ async function handler() {
return cache.tryGet(link, async () => {
const result = await got(link);
const $ = cherrio.load(result.data);
const $ = cheerio.load(result.data);
return {
title,
author: $('.user_name').text(),

View File

@ -2,6 +2,7 @@ import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import cache from '@/utils/cache';
import CryptoJS from 'crypto-js/crypto-js';
import { Route } from '@/types';
export const route: Route = {
path: '/hqsz',

View File

@ -1,6 +1,6 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import cherrio from 'cheerio';
import * as cheerio from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@ -32,7 +32,7 @@ async function handler() {
const link = 'https://telegram.org/blog';
const res = await got(link);
const $$ = cherrio.load(res.body);
const $$ = cheerio.load(res.body);
const items = await Promise.all(
$$('.dev_blog_card_link_wrap')
@ -42,7 +42,7 @@ async function handler() {
const link = 'https://telegram.org' + $.attr('href');
return cache.tryGet(link, async () => {
const result = await got(link);
const $ = cherrio.load(result.body);
const $ = cheerio.load(result.body);
return {
title: $('#dev_page_title').text(),
link,

View File

@ -1,5 +1,31 @@
import type { Context } from 'hono';
// Make sure it's synchronise with scripts/workflow/data.ts
type Category =
| 'social-media'
| 'new-media'
| 'traditional-media'
| 'bbs'
| 'blog'
| 'programming'
| 'design'
| 'live'
| 'multimedia'
| 'picture'
| 'anime'
| 'program-update'
| 'university'
| 'forecast'
| 'travel'
| 'shopping'
| 'game'
| 'reading'
| 'government'
| 'study'
| 'journal'
| 'finance'
| 'other';
// rss
export type DataItem = {
title: string;
@ -72,7 +98,7 @@ interface NamespaceItem {
/**
* The classification of the namespace, which will be written into the corresponding classification document
*/
categories?: string[];
categories?: Category[];
/**
* Hints and additional explanations for users using this namespace, it will be inserted into the documentation
@ -117,7 +143,7 @@ interface RouteItem {
/**
* The handler function of the route
*/
handler: (ctx?: Context) => Promise<Data> | Data;
handler: (ctx: Context) => Promise<Data> | Data;
/**
* An example URL of the route
@ -137,7 +163,7 @@ interface RouteItem {
/**
* The classification of the route, which will be written into the corresponding classification documentation
*/
categories?: string[];
categories?: Category[];
/**
* Special features of the route, such as what configuration items it depends on, whether it is strict anti-crawl, whether it supports a certain function and so on