forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add fish shell release notes (DIYgod#12139)
* feat(route): add fish shell release notes * fix(route): fish shell release notes * fix(route): fish shell release notes ---------
- Loading branch information
x2cf
authored
Mar 20, 2023
1 parent
3d6d8eb
commit c22b0c1
Showing
6 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const cheerio = require('cheerio'); | ||
const got = require('@/utils/got'); | ||
const config = require('@/config').value; | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const link = 'https://fishshell.com/docs/current/relnotes.html'; | ||
const data = await ctx.cache.tryGet(link, async () => (await got(link)).data, config.cache.contentExpire, false); | ||
const $ = cheerio.load(data); | ||
ctx.state.data = { | ||
link, | ||
title: 'Release notes — fish-shell', | ||
language: 'en', | ||
item: $('#release-notes > section') | ||
.map((_, item) => { | ||
const title = $(item).find('h2').contents().first().text(); | ||
const date = title.match(/\(released (.+?)\)/)?.[1]; | ||
return { | ||
title, | ||
link: new URL($(item).find('a').attr('href'), link).href, | ||
pubDate: date ? parseDate(date, 'MMMM D, YYYY') : undefined, | ||
description: $(item).html(), | ||
}; | ||
}) | ||
.get(), | ||
}; | ||
}; |
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,3 @@ | ||
module.exports = { | ||
'/': ['x2cf'], | ||
}; |
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,13 @@ | ||
module.exports = { | ||
'fishshell.com': { | ||
_name: 'fish shell', | ||
'.': [ | ||
{ | ||
title: 'Release Notes', | ||
docs: 'https://docs.rsshub.app/program-update.html#fish-shell', | ||
source: ['/'], | ||
target: '/fishshell', | ||
}, | ||
], | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = function (router) { | ||
router.get('/', require('./index')); | ||
}; |