feat(route): cmpxchg8b (#13802)
* feat(route): cmpxchg8b Signed-off-by: yuguorui <yuguorui@pku.edu.cn> * Update website/docs/routes/programming.mdx * docs: move to blog --------- Signed-off-by: yuguorui <yuguorui@pku.edu.cn>
This commit is contained in:
parent
1c693307a6
commit
5adb4a4d8c
|
|
@ -0,0 +1,43 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const baseUrl = 'https://lock.cmpxchg8b.com/';
|
||||
const title = 'cmpxchg8b';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data: response } = await got(baseUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const author = $('p.author').text().trim();
|
||||
const list = $('section#articles section')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('li').text(),
|
||||
link: new URL(item.find('li a').attr('href'), baseUrl).toString(),
|
||||
author,
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
// extract the body but removing <nav> and <footer>
|
||||
const body = $('body');
|
||||
body.find('nav, footer').remove();
|
||||
item.description = body.html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: new URL('#articles', baseUrl).toString(),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/articles': ['yuguorui'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'cmpxchg8b.com': {
|
||||
_name: 'cmpxchg8b',
|
||||
lock: [
|
||||
{
|
||||
title: '文章 articles',
|
||||
docs: 'https://docs.rsshub.app/routes/blog#cmpxchg8b',
|
||||
source: ['/articles'],
|
||||
target: '/cmpxchg8b/articles',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/articles', require('./articles'));
|
||||
};
|
||||
|
|
@ -28,6 +28,12 @@
|
|||
|
||||
<Route author="emdoe" example="/benedictevans" path="/benedictevans"/>
|
||||
|
||||
## cmpxchg8b {#cmpxchg8b}
|
||||
|
||||
### Articles {#cmpxchg8b-articles}
|
||||
|
||||
<Route author="yuguorui" example="/cmpxchg8b/articles" path="/cmpxchg8b/articles"/>
|
||||
|
||||
## CSDN {#csdn}
|
||||
|
||||
### User Feed {#csdn-user-feed}
|
||||
|
|
|
|||
|
|
@ -1565,4 +1565,3 @@ Stay up to date on the latest React news, tutorials, resources, and more. Delive
|
|||
### 热门 {#zhong-cheng-fan-yi-re-men}
|
||||
|
||||
<Route author="SirM2z" example="/zcfy/hot" path="/zcfy/hot"/>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue