Add a global title length cap. And localisation for Instagram. (#670)
This commit is contained in:
parent
b8bdf9ca58
commit
571636b4a8
|
|
@ -29,6 +29,10 @@ module.exports = async (ctx, next) => {
|
|||
template = path.resolve(__dirname, '../views/rss.art');
|
||||
break;
|
||||
}
|
||||
// trim title length
|
||||
ctx.state.data.item.forEach((item) => {
|
||||
item.title = item.title.length > 80 ? `${item.title.slice(0, 80)}...` : item.title;
|
||||
});
|
||||
|
||||
const data = {
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ module.exports = async (ctx) => {
|
|||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name}(@${id}) 的 Instagram`,
|
||||
title: `${name}(@${id})'s Instagram`,
|
||||
link: `https://www.instagram.com/${id}/`,
|
||||
description: $('meta[name="description"]').attr('content'),
|
||||
item: list.map((item, index) => {
|
||||
|
|
@ -54,11 +54,11 @@ module.exports = async (ctx) => {
|
|||
let tip = '';
|
||||
switch (item.__typename) {
|
||||
case 'GraphVideo':
|
||||
type = '[视频] ';
|
||||
tip = '打开原文播放视频: ';
|
||||
type = '[视频/Video] ';
|
||||
tip = '打开原文播放视频/click to play the video: ';
|
||||
break;
|
||||
case 'GraphSidecar':
|
||||
type = '[组图] ';
|
||||
type = '[组图/Carousel] ';
|
||||
break;
|
||||
}
|
||||
let imgTPL = '';
|
||||
|
|
@ -66,7 +66,7 @@ module.exports = async (ctx) => {
|
|||
imgTPL += `<img referrerpolicy="no-referrer" src="${images[index][i]}"><br>`;
|
||||
}
|
||||
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) || '无题'}`,
|
||||
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}`,
|
||||
pubDate: new Date(item.taken_at_timestamp * 1000).toUTCString(),
|
||||
link: `https://www.instagram.com/p/${item.shortcode}/`,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
|||
const description = weiboUtils.format(item.mblog);
|
||||
const title = description.replace(/<img.*?>/g, '[图片]').replace(/<.*?>/g, '');
|
||||
return {
|
||||
title: title.length > 24 ? title.slice(0, 24) + '...' : title,
|
||||
title,
|
||||
description: description,
|
||||
pubDate: weiboUtils.getTime(item.mblog.created_at),
|
||||
link: `https://weibo.com/${uid}/${item.mblog.bid}`,
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ module.exports = async (ctx) => {
|
|||
.text()
|
||||
.replace(/^\s+|\s+$/g, '')
|
||||
.replace(/\u200B/g, '');
|
||||
if (wb.title.length > 24) {
|
||||
wb.title = wb.title.slice(0, 24) + '...';
|
||||
} else if (wb.title === '') {
|
||||
if (wb.title === '') {
|
||||
wb.title = '[图片]';
|
||||
}
|
||||
wb.description = titleEle
|
||||
|
|
|
|||
Loading…
Reference in New Issue