fix: show lofter user title (#4750)

This commit is contained in:
hoilc 2020-05-12 14:26:56 +08:00 committed by GitHub
parent 9bccbc2c92
commit ab59be55aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -1879,4 +1879,15 @@
},
],
},
'lofter.com': {
_name: 'Lofter',
www: [
{
title: '话题 (标签)',
docs: 'https://docs.rsshub.app/social-media.html#lofter',
source: ['/tag/:name', '/tag/:name/:type'],
target: (params) => `/lofter/tag/${params.name}/${params.type || ''}`,
},
],
},
});

View File

@ -21,11 +21,17 @@ module.exports = async (ctx) => {
supportposttypes: '1,2,3,4,5,6',
},
});
if (!response.data.response || response.data.response.posts.length === 0) {
throw 'Blog Not Found';
}
const data = response.data.response.posts;
const blogNickName = data[0].post.blogInfo.blogNickName;
const selfIntro = data[0].post.blogInfo.selfIntro;
ctx.state.data = {
title: `${ctx.params.username}.lofter.com`,
link: blogdomain,
description: `${ctx.params.username}.lofter.com`,
title: `${blogNickName} - lofter`,
link: `https://${blogdomain}`,
description: selfIntro,
item: data.map((item) => {
let content = item.post.content;
const title = item.post.title || item.post.noticeLinkTitle;
@ -41,7 +47,7 @@ module.exports = async (ctx) => {
pubDate: new Date(item.post.publishTime).toUTCString(),
link: item.post.blogPageUrl,
guid: item.post.blogPageUrl,
author: item.post.blogInfo.blogNickName,
author: blogNickName,
};
}),
};