diff --git a/assets/radar-rules.js b/assets/radar-rules.js index ad513b46a..d6a042898 100755 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -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 || ''}`, + }, + ], + }, }); diff --git a/lib/routes/lofter/posts.js b/lib/routes/lofter/posts.js index b1472e29d..ba5ee955e 100644 --- a/lib/routes/lofter/posts.js +++ b/lib/routes/lofter/posts.js @@ -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, }; }), };