diff --git a/lib/v2/mihoyo/bbs/img-ranking.js b/lib/v2/mihoyo/bbs/img-ranking.js
index 6d988b7f9..e2a3dd51a 100644
--- a/lib/v2/mihoyo/bbs/img-ranking.js
+++ b/lib/v2/mihoyo/bbs/img-ranking.js
@@ -1,10 +1,6 @@
const got = require('@/utils/got');
-const { art } = require('@/utils/render');
-const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
const { DATA_MAP, RANKING_TYPE_MAP } = require('./static-data');
-
-const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
+const { post2item } = require('./utils');
const getGameInfo = (game) => ({
gids: DATA_MAP[game]?.gids,
@@ -75,32 +71,7 @@ module.exports = async (ctx) => {
throw new Error('未获取到数据!');
}
const title = `米游社-${game_title}-${forum_title}${cate_title ? `-${cate_title}` : ''}-${type_title}`;
- const items = list.map((e) => {
- const author = e.user.nickname;
- const title = e.post.subject;
- const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
- let describe = e.post.content || '';
- try {
- describe = JSON.parse(e.post.content).describe;
- } catch (error) {
- if (!(error instanceof SyntaxError)) {
- throw error;
- }
- }
- const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
- const pubDate = parseDate(e.post.created_at * 1000);
- const upvotes = e.stat.like_num;
- const comments = e.stat.reply_num;
- return {
- author,
- title,
- link,
- description,
- pubDate,
- upvotes,
- comments,
- };
- });
+ const items = list.map((e) => post2item(e));
const data = {
title,
link: url,
diff --git a/lib/v2/mihoyo/bbs/official.js b/lib/v2/mihoyo/bbs/official.js
index 00639fd6f..9e38ea88b 100644
--- a/lib/v2/mihoyo/bbs/official.js
+++ b/lib/v2/mihoyo/bbs/official.js
@@ -1,7 +1,5 @@
const got = require('@/utils/got');
-const { art } = require('@/utils/render');
-const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
+const { post2item } = require('./utils');
// 游戏id
const GITS_MAP = {
1: '崩坏三',
@@ -19,8 +17,6 @@ const TYPE_MAP = {
3: '资讯',
};
-const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
-
module.exports = async (ctx) => {
const { gids, type = '2', page_size = '20', last_id = '' } = ctx.params;
const query = new URLSearchParams({
@@ -39,20 +35,7 @@ module.exports = async (ctx) => {
throw new Error('未获取到数据!');
}
const title = `米游社 - ${GITS_MAP[gids] || ''} - ${TYPE_MAP[type] || ''}`;
- const items = list.map((e) => {
- const author = e.user.nickname;
- const title = e.post.subject;
- const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
- const description = renderDescription(e.post.content, e.post.images);
- const pubDate = parseDate(e.post.created_at * 1000);
- return {
- author,
- title,
- link,
- description,
- pubDate,
- };
- });
+ const items = list.map((e) => post2item(e));
const data = {
title,
link: url,
diff --git a/lib/v2/mihoyo/bbs/timeline.js b/lib/v2/mihoyo/bbs/timeline.js
index 6c2b508ce..3c7e84fc0 100644
--- a/lib/v2/mihoyo/bbs/timeline.js
+++ b/lib/v2/mihoyo/bbs/timeline.js
@@ -1,11 +1,7 @@
const got = require('@/utils/got');
-const { art } = require('@/utils/render');
-const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
const cache = require('./cache');
const config = require('@/config').value;
-
-const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
+const { post2item } = require('./utils');
module.exports = async (ctx) => {
if (!config.mihoyo.cookie) {
@@ -34,32 +30,7 @@ module.exports = async (ctx) => {
}
const { nickname: username } = await cache.getUserFullInfo(ctx, '');
const title = `米游社 - ${username} 的关注动态`;
- const items = list.map((e) => {
- const author = e.user.nickname;
- const title = e.post.subject;
- const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
- let describe = e.post.content || '';
- try {
- describe = JSON.parse(e.post.content).describe;
- } catch (error) {
- if (!(error instanceof SyntaxError)) {
- throw error;
- }
- }
- const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
- const pubDate = parseDate(e.post.created_at * 1000);
- const upvotes = e.stat.like_num;
- const comments = e.stat.reply_num;
- return {
- author,
- title,
- link,
- description,
- pubDate,
- upvotes,
- comments,
- };
- });
+ const items = list.map((e) => post2item(e));
const data = {
title,
diff --git a/lib/v2/mihoyo/bbs/user-post.js b/lib/v2/mihoyo/bbs/user-post.js
index c68302ae3..547ff0fa3 100644
--- a/lib/v2/mihoyo/bbs/user-post.js
+++ b/lib/v2/mihoyo/bbs/user-post.js
@@ -1,9 +1,5 @@
const got = require('@/utils/got');
-const { art } = require('@/utils/render');
-const path = require('path');
-const { parseDate } = require('@/utils/parse-date');
-
-const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
+const { post2item } = require('./utils');
module.exports = async (ctx) => {
const { uid } = ctx.params;
@@ -25,32 +21,7 @@ module.exports = async (ctx) => {
}
const username = list[0]?.user.nickname;
const title = `米游社 - ${username} 的发帖`;
- const items = list.map((e) => {
- const author = e.user.nickname;
- const title = e.post.subject;
- const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
- let describe = e.post.content || '';
- try {
- describe = JSON.parse(e.post.content).describe;
- } catch (error) {
- if (!(error instanceof SyntaxError)) {
- throw error;
- }
- }
- const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
- const pubDate = parseDate(e.post.created_at * 1000);
- const upvotes = e.stat.like_num;
- const comments = e.stat.reply_num;
- return {
- author,
- title,
- link,
- description,
- pubDate,
- upvotes,
- comments,
- };
- });
+ const items = list.map((e) => post2item(e));
const data = {
title,
diff --git a/lib/v2/mihoyo/bbs/utils.js b/lib/v2/mihoyo/bbs/utils.js
new file mode 100644
index 000000000..165d8fdd0
--- /dev/null
+++ b/lib/v2/mihoyo/bbs/utils.js
@@ -0,0 +1,34 @@
+const { art } = require('@/utils/render');
+const path = require('path');
+const { parseDate } = require('@/utils/parse-date');
+
+const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
+
+module.exports = {
+ post2item(e) {
+ const author = e.user.nickname;
+ const title = e.post.subject;
+ const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
+ let describe = e.post.content || '';
+ try {
+ describe = JSON.parse(e.post.content).describe;
+ } catch (error) {
+ if (!(error instanceof SyntaxError)) {
+ throw error;
+ }
+ }
+ const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
+ const pubDate = parseDate(e.post.created_at * 1000);
+ const upvotes = e.stat.like_num;
+ const comments = e.stat.reply_num;
+ return {
+ author,
+ title,
+ link,
+ description,
+ pubDate,
+ upvotes,
+ comments,
+ };
+ },
+};
diff --git a/website/docs/routes/government.mdx b/website/docs/routes/government.mdx
index 71ca7b15e..da920cce8 100644
--- a/website/docs/routes/government.mdx
+++ b/website/docs/routes/government.mdx
@@ -12,9 +12,9 @@
-## Constitutional Court of Baden-Württemberg (Germany) {#constitutional-court-of-baden-w%C3%BCrttemberg-germany}
+## Constitutional Court of Baden-Württemberg (Germany) {#constitutional-court-of-baden-wvrttemberg-germany}
-### Press releases {#constitutional-court-of-baden-w%C3%BCrttemberg-germany-press-releases}
+### Press releases {#constitutional-court-of-baden-wvrttemberg-germany-press-releases}
diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx
index abca26609..c69791094 100644
--- a/website/docs/routes/other.mdx
+++ b/website/docs/routes/other.mdx
@@ -121,7 +121,7 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store)
-### Macao Pagina Electrónica Especial Contra Epidemias: What’s New {#corona-virus-disease-2019-macao-pagina-electr%C3%B3nica-especial-contra-epidemias-what-s-new}
+### Macao Pagina Electrónica Especial Contra Epidemias: What’s New {#corona-virus-disease-2019-macao-pagina-electronica-especial-contra-epidemias-what-s-new}
Official Website: [https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx](https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx)