Files
RSSHub/lib/routes/dlnews/utils.ts
T
Nya Candy cce3bdb4fe fix(route): 使用 ofetch() 替换一些 got().json() (#15780)
* chore: some massive adoption from got().json() to ofetch()

Not sure if everything works fine (some may still have problems other than fakeGot & json issues), but this might have some help.

BTW maybe we can start "The Migration" project to update some outdated routes to new format 🤔

* fix: some other issues

* fix: query

* fix: luogu user blog & modb topic

* fix: modb topic response

* fix: query options in freebuf

---------
2024-06-01 01:10:15 +08:00

23 lines
810 B
TypeScript

import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://www.dlnews.com';
const getData = async (url) => (await ofetch(url)).content_elements;
const getList = (data) =>
data.map((value) => {
const { _id, headlines, description, publish_date, website_url, taxonomy, credits, promo_items } = value;
return {
id: _id,
title: headlines.basic,
link: `${baseUrl}${website_url}`,
description: description.basic,
author: credits.by.map((v) => v.name).join(', '),
itunes_item_image: promo_items.basic.url,
pubDate: parseDate(publish_date),
category: taxonomy.sections.map((v) => v.name).join(', '),
};
});
export { getData, getList };