diff --git a/docs/en/programming.md b/docs/en/programming.md index 5a047117e3..396d6ef91c 100644 --- a/docs/en/programming.md +++ b/docs/en/programming.md @@ -239,3 +239,9 @@ Website: https://news.ycombinator.com/ | featured | trending | trending_m | trending_d | popular | new | + +## react + +### react-native + + diff --git a/docs/programming.md b/docs/programming.md index a12794e21b..87f5549428 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -322,6 +322,12 @@ GitHub 官方也提供了一些 RSS: +## react + +### react-native + + + ## Scala ### Scala Blog diff --git a/lib/router.js b/lib/router.js index 2eba18a30d..42b0dcf697 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4024,4 +4024,6 @@ router.get('/gf-cn/news/:category?', require('./routes/gf-cn/news')); // Eagle router.get('/eagle/changelog/:language?', require('./routes/eagle/changelog')); +// react +router.get('/react/react-native-weekly', require('./routes/react/react-native-weekly')); module.exports = router; diff --git a/lib/routes/react/react-native-weekly.js b/lib/routes/react/react-native-weekly.js new file mode 100644 index 0000000000..09dd25d858 --- /dev/null +++ b/lib/routes/react/react-native-weekly.js @@ -0,0 +1,35 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const host = 'https://reactnative.cc'; + const response = await got({ + method: 'get', + url: `${host}/issues.html`, + }); + const data = response.data; + const $ = cheerio.load(data); + const newestHref = $('.past-issues-header>ul').first().find('li a').attr('href'); + const detailResponse = await got({ + method: 'get', + url: `${host}${newestHref}`, + }); + const $2 = cheerio.load(detailResponse.data); + const list = $2('.mcnCaptionBottomContent .mcnTextContent a', 'body'); + + ctx.state.data = { + title: 'react-native-weekly', + link: 'https://reactnative.cc', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.text().replace(/\s{2}/g, ''), + link: item.attr('href'), + }; + }) + .get(), + }; +};