mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: support opencc
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const he = require('he');
|
||||
const mercury_parser = require('@postlight/mercury-parser');
|
||||
const cheerio = require('cheerio');
|
||||
const OpenCC = require('opencc');
|
||||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
|
||||
@@ -224,6 +225,16 @@ module.exports = async (ctx, next) => {
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
// opencc
|
||||
if (ctx.query.opencc) {
|
||||
const converter = new OpenCC(`${ctx.query.opencc}.json`);
|
||||
const tasks = ctx.state.data.item.map(async (item) => {
|
||||
item.title = await converter.convertPromise(item.title);
|
||||
item.description = await converter.convertPromise(item.description);
|
||||
});
|
||||
await Promise.all(tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user