-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
1,832 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Route, DataItem } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import parser from '@/utils/rss-parser'; | ||
import cache from '@/utils/cache'; | ||
|
||
export const route: Route = { | ||
path: '/blog', | ||
categories: ['blog'], | ||
example: '/baoyu/blog', | ||
radar: [ | ||
{ | ||
source: ['baoyu.io/'], | ||
}, | ||
], | ||
url: 'baoyu.io/', | ||
name: 'Blog', | ||
maintainers: ['liyaozhong'], | ||
handler, | ||
description: '宝玉 - 博客文章', | ||
}; | ||
|
||
async function handler() { | ||
const rootUrl = 'https://baoyu.io'; | ||
const feedUrl = `${rootUrl}/feed.xml`; | ||
|
||
const feed = await parser.parseURL(feedUrl); | ||
|
||
const items = await Promise.all( | ||
feed.items.map((item) => { | ||
const link = item.link; | ||
|
||
return cache.tryGet(link as string, async () => { | ||
const response = await got(link); | ||
const $ = load(response.data); | ||
|
||
const container = $('.container'); | ||
const content = container.find('.prose').html() || ''; | ||
|
||
return { | ||
title: item.title, | ||
description: content, | ||
link, | ||
pubDate: item.pubDate ? parseDate(item.pubDate) : undefined, | ||
author: item.creator || '宝玉', | ||
} as DataItem; | ||
}); | ||
}) | ||
); | ||
|
||
return { | ||
title: '宝玉的博客', | ||
link: rootUrl, | ||
item: items, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '宝玉', | ||
url: 'baoyu.io', | ||
description: '宝玉的博客', | ||
lang: 'zh-CN', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.