Skip to content

Commit 2e756e0

Browse files
authored
fix(route/baoyu): handle HTTP redirect for feed.xml (#20968)
1 parent ad3acba commit 2e756e0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/routes/baoyu/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { load } from 'cheerio';
22

33
import type { DataItem, Route } from '@/types';
44
import cache from '@/utils/cache';
5-
import got from '@/utils/got';
5+
import ofetch from '@/utils/ofetch';
66
import { parseDate } from '@/utils/parse-date';
77
import parser from '@/utils/rss-parser';
88

@@ -17,7 +17,7 @@ export const route: Route = {
1717
],
1818
url: 'baoyu.io/',
1919
name: 'Blog',
20-
maintainers: ['liyaozhong'],
20+
maintainers: ['liyaozhong', 'Circloud'],
2121
handler,
2222
description: '宝玉 - 博客文章',
2323
};
@@ -26,15 +26,16 @@ async function handler() {
2626
const rootUrl = 'https://baoyu.io';
2727
const feedUrl = `${rootUrl}/feed.xml`;
2828

29-
const feed = await parser.parseURL(feedUrl);
29+
const response = await ofetch(feedUrl);
30+
const feed = await parser.parseString(response);
3031

3132
const items = await Promise.all(
3233
feed.items.map((item) => {
3334
const link = item.link;
3435

3536
return cache.tryGet(link as string, async () => {
36-
const response = await got(link);
37-
const $ = load(response.data);
37+
const response = await ofetch(link as string);
38+
const $ = load(response);
3839

3940
const container = $('.container');
4041
const content = container.find('.prose').html() || '';

0 commit comments

Comments
 (0)