Files
RSSHub/lib/routes/firefox/release.js
2019-05-15 15:27:15 +08:00

31 lines
951 B
JavaScript

const axios = require('@/utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const { platform } = ctx.params;
let devicePlatform = platform.replace('-', '/');
if (devicePlatform === 'desktop') {
devicePlatform = '';
}
const link = `https://www.mozilla.org/en-US/firefox/${devicePlatform}/notes/`;
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const version = $('.c-release-version').text();
const pubDate = new Date($('.c-release-date').text()).toUTCString();
ctx.state.data = {
title: `Firefox ${platform} release note`,
link,
item: [
{
title: `Firefox ${platform} ${version} release note`,
link,
description: $('.c-release-notes').html(),
guid: `${platform} ${version}`,
pubDate,
},
],
};
};