feat(route): add VMware Flings (#10315)
This commit is contained in:
parent
09255c52a4
commit
fdc5b09f90
|
|
@ -460,6 +460,12 @@ Refer to [#minecraft](/en/game.html#minecraft)
|
|||
|
||||
<RouteEn author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
|
||||
|
||||
## VMware
|
||||
|
||||
### Flings
|
||||
|
||||
<RouteEn author="nczitzk" example="/vmware/flings" path="/vmware/flings"/>
|
||||
|
||||
## Western Digital
|
||||
|
||||
### Download
|
||||
|
|
|
|||
|
|
@ -547,6 +547,12 @@ pageClass: routes
|
|||
|
||||
<Route author="nczitzk" example="/typora/changelog-dev/macOS" path="/typora/changelog-dev/:os" :paramsDesc="['操作系统类型, 可选 `macOS` 或 `Windows` 与 `Linux`,默认为 `macOS`']"/>
|
||||
|
||||
## VMware
|
||||
|
||||
### Flings
|
||||
|
||||
<Route author="nczitzk" example="/vmware/flings" path="/vmware/flings"/>
|
||||
|
||||
## Western Digital
|
||||
|
||||
### Download
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://flings.vmware.com';
|
||||
const currentUrl = `${rootUrl}/flings`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.clickable')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const title = item.find('.fling-title');
|
||||
const version = item.find('.fling-version').text();
|
||||
|
||||
return {
|
||||
title: `${title.text()} (${version})`,
|
||||
link: `${rootUrl}${title.attr('href')}#${version}`,
|
||||
pubDate: parseDate(item.find('.date').text(), 'MMM DD, YYYY'),
|
||||
category: item
|
||||
.find('.fling-tags a')
|
||||
.toArray()
|
||||
.map((a) => $(a).text()),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('#contributors, #similar-flings').remove();
|
||||
|
||||
item.description = content('article').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/flings': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'vmware.com': {
|
||||
_name: 'VMware',
|
||||
flings: [
|
||||
{
|
||||
title: 'Flings',
|
||||
docs: 'https://docs.rsshub.app/program-update.html#vmware-flings',
|
||||
source: ['/flings', '/'],
|
||||
target: '/vmware/flings',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/flings', require('./flings'));
|
||||
};
|
||||
Loading…
Reference in New Issue