mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 18:18:06 +08:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const md = require('markdown-it')({
|
|
html: true,
|
|
});
|
|
|
|
module.exports = async (ctx) => {
|
|
const rootUrl = 'https://imagemagick.org';
|
|
const currentUrl = `${rootUrl}/script/download.php`;
|
|
const logUrl = 'https://github.com/ImageMagick/Website/blob/main/ChangeLog.md';
|
|
const rawLogUrl = 'https://raw.githubusercontent.com/ImageMagick/Website/main/ChangeLog.md';
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: rawLogUrl,
|
|
});
|
|
|
|
const $ = cheerio.load(md.render(response.data));
|
|
|
|
const items = $('h2')
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
|
|
const title = item.text();
|
|
|
|
let description = '';
|
|
item.nextUntil('h2').each(function () {
|
|
description += $(this).html();
|
|
});
|
|
|
|
return {
|
|
title,
|
|
description,
|
|
link: `${logUrl}#${title.replace(/\s+/g, '-').replace(/\./g, '')}`,
|
|
pubDate: parseDate(title.match(/- (\d{4}-\d{2}-\d{2})/)[1]),
|
|
};
|
|
});
|
|
|
|
ctx.state.data = {
|
|
title: 'ImageMagick - ChangeLog',
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|