feat: v3 migration - 3/n

This commit is contained in:
DIYgod
2024-02-28 16:33:13 +08:00
parent 185b5d1441
commit fdf3fcac57
611 changed files with 3540 additions and 3528 deletions
+7 -7
View File
@@ -1,18 +1,18 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const routeParams = ctx.params.routeParams;
const routeParams = ctx.req.param('routeParams');
const baseURL = 'https://sourceforge.net';
const link = `https://sourceforge.net/directory/?${routeParams.toString()}`;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const $ = load(response.data);
const itemList = $('ul.projects li[itemprop=itemListElement]');
ctx.state.data = {
ctx.set('data', {
title: $('.content h1').text().trim(),
link,
item: itemList.toArray().map((element) => {
@@ -29,5 +29,5 @@ module.exports = async (ctx) => {
pubDate,
};
}),
};
});
};