decode HTML entity

This commit is contained in:
DIYgod
2018-09-17 00:18:37 +08:00
parent 635de62e00
commit 7c6344010e
3 changed files with 14 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
const art = require('art-template');
const path = require('path');
const config = require('../config');
const he = require('he');
const typeRegrx = /\.(atom|rss|json)$/;
module.exports = async (ctx, next) => {
@@ -40,6 +41,14 @@ module.exports = async (ctx, next) => {
}
});
ctx.state.data.title && (ctx.state.data.title = he.decode(ctx.state.data.title));
ctx.state.data.description && (ctx.state.data.description = he.decode(ctx.state.data.description));
ctx.state.data.item &&
ctx.state.data.item.forEach((item) => {
item.title && (item.title = he.decode(item.title));
item.description && (item.description = he.decode(item.description));
});
const data = {
lastBuildDate: new Date().toUTCString(),
updated: new Date().toISOString(),

View File

@@ -50,6 +50,7 @@
"form-data": "^2.3.2",
"git-rev-sync": "1.12.0",
"googleapis": "33.0.0",
"he": "^1.1.1",
"iconv-lite": "0.4.24",
"imgur": "^0.2.1",
"json-bigint": "0.3.0",

View File

@@ -3564,6 +3564,10 @@ he@1.1.x, he@^1.1.0:
version "1.1.1"
resolved "https://registry.npmjs.org/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
he@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
hmac-drbg@^1.0.0:
version "1.0.1"
resolved "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"