Files
RSSHub/lib/routes/kcna/utils.ts
T
Tony 5527d18de9 refactor: remove unnecessary trim/first/last (#22837)
* refactor: remove unnecessary trim/first/last

* refactor(types): allow null in DataItem.description

* refactor: remove unnecessary fallback

* refactor(types): allow null in Data.description

* refactor: remove unnecessary fallback

* refactor: remove .clone()

* refactor: refine json content text

* fIx: cognition

* fix: more fixes

* fix(route/jiemian): use api

* fix(route/jandan): housekeeping

add back maintainers from #8904

* fix(route/kcna/news): update source and target mappings

* fix(route/jandan): sanitize HTML content in titles

* refactor: remove unnecessary referer

* fix(route/jinse): regex
2026-07-27 22:23:57 +08:00

26 lines
650 B
TypeScript

import { load } from 'cheerio';
import cache from '@/utils/cache';
import ofetch from '@/utils/ofetch';
export const fixDesc = ($, elem) => {
// <august_name>???</august_name> => <b>???</b>
const $elem = $(elem);
$elem.find('august_name').each((_, item) => {
item.name = 'b';
});
return $elem.html();
};
export const fetchPhoto = (url) =>
cache.tryGet(url, async () => {
const response = await ofetch(url);
const $ = load(response);
return $('.gallery img')
.removeAttr('class')
.toArray()
.map((item) => $.html(item))
.join('<br>');
});