diff --git a/middleware/template.js b/middleware/template.js
index 7fa9b64a0..283e8b5a2 100644
--- a/middleware/template.js
+++ b/middleware/template.js
@@ -31,7 +31,13 @@ module.exports = async (ctx, next) => {
}
// trim title length
ctx.state.data.item.forEach((item) => {
- item.title = item.title.length > 80 ? `${item.title.slice(0, 80)}...` : item.title;
+ for (let length = 0, i = 0; i < item.title.length; i++) {
+ length += Buffer.from(item.title[i]).length !== 1 ? 2 : 1;
+ if (length > 100) {
+ item.title = `${item.title.slice(0, i)}...`;
+ break;
+ }
+ }
});
const data = {
diff --git a/routes/disqus/posts.js b/routes/disqus/posts.js
index 8b9116ec2..05c69768f 100644
--- a/routes/disqus/posts.js
+++ b/routes/disqus/posts.js
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
item: data.map((item) => {
const thread = threads.filter((i) => i.id === item.thread)[0];
return {
- title: `${item.author.name}: ${item.raw_message > 24 ? item.raw_message.slice(0, 24) + '...' : item.raw_message}`,
+ title: `${item.author.name}: ${item.raw_message}`,
description: `${item.author.name} 在《${thread.clean_title}》中发表评论: ${item.message}`,
pubDate: new Date(item.createdAt).toUTCString(),
link: `${thread.link}/#comment-${item.id}`,
diff --git a/routes/instagram/user.js b/routes/instagram/user.js
index b577d88a0..b53ecb618 100644
--- a/routes/instagram/user.js
+++ b/routes/instagram/user.js
@@ -65,9 +65,10 @@ module.exports = async (ctx) => {
for (let i = 0; i < images[index].length; i++) {
imgTPL += `
`;
}
+ const title = (item.edge_media_to_caption.edges && item.edge_media_to_caption.edges[0] && item.edge_media_to_caption.edges[0].node.text) || '无题/Untitled';
return {
- title: `${type}${(item.edge_media_to_caption.edges && item.edge_media_to_caption.edges[0] && item.edge_media_to_caption.edges[0].node.text) || '无题/Untitled'}`,
- description: `${tip}${imgTPL}`,
+ title: `${type}${title}`,
+ description: `${title}
${tip}${imgTPL}`,
pubDate: new Date(item.taken_at_timestamp * 1000).toUTCString(),
link: `https://www.instagram.com/p/${item.shortcode}/`,
};
diff --git a/routes/telegram/channel.js b/routes/telegram/channel.js
index d51367574..e555b28ac 100644
--- a/routes/telegram/channel.js
+++ b/routes/telegram/channel.js
@@ -83,7 +83,7 @@ module.exports = async (ctx) => {
}
return {
- title: text.length > 24 ? text.slice(0, 24) + '...' : text,
+ title: text,
description: html,
pubDate: new Date(item.date * 1000).toUTCString(),
link: `https://t.me/${username}/${item.message_id}`,
diff --git a/routes/twitter/user.js b/routes/twitter/user.js
index 1049ac4c9..95b27f8ce 100644
--- a/routes/twitter/user.js
+++ b/routes/twitter/user.js
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
url += ``;
});
return {
- title: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.full_text.length > 30 ? item.full_text.slice(0, 30) + '...' : item.full_text}`,
+ title: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.full_text}`,
description: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.full_text}${url}${img}`,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://twitter.com/${id}/status/${item.id_str}`,
diff --git a/routes/weibo/keyword.js b/routes/weibo/keyword.js
index f8853c2e7..aab4ae5d9 100644
--- a/routes/weibo/keyword.js
+++ b/routes/weibo/keyword.js
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
item: data.map((item) => {
const title = item.mblog.text.replace(//g, '[图片]').replace(/<.*?>/g, '');
return {
- title: `${item.mblog.user.screen_name}: ${title.length > 24 ? title.slice(0, 24) + '...' : title}`,
+ title: `${item.mblog.user.screen_name}: ${title}`,
description: `${item.mblog.user.screen_name}: ${weiboUtils.format(item.mblog)}`,
pubDate: weiboUtils.getTime(item.mblog.created_at),
link: `https://weibo.com/${item.mblog.user.id}/${item.mblog.bid}`,
diff --git a/routes/zhihu/activities.js b/routes/zhihu/activities.js
index 8568b9540..d0a95c1aa 100644
--- a/routes/zhihu/activities.js
+++ b/routes/zhihu/activities.js
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
url = `https://zhuanlan.zhihu.com/p/${detail.id}`;
break;
case 'pin':
- title = detail.excerpt_title.length > 17 ? detail.excerpt_title.slice(0, 17) + '...' : detail.excerpt_title;
+ title = detail.excerpt_title;
detail.content.forEach((contentItem) => {
if (contentItem.type === 'text') {
text = `${contentItem.own_text}
`;