From 12a7390e380471cd98b5ea388cb57c6afe89c7ad Mon Sep 17 00:00:00 2001 From: Liu Date: Sat, 2 Jun 2018 11:03:15 +0800 Subject: [PATCH] rss: add author field to v2ex (#229) * rss: add author field to v2ex * rss: add username to v2ex description * rss: v2ex use content_rendered to description --- routes/v2ex/topics.js | 3 ++- views/json.art | 3 +++ views/rss.art | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/routes/v2ex/topics.js b/routes/v2ex/topics.js index 74ec638a49..2d5be73110 100644 --- a/routes/v2ex/topics.js +++ b/routes/v2ex/topics.js @@ -27,12 +27,13 @@ module.exports = async (ctx) => { description: `V2EX-${title}`, item: data.map((item) => ({ title: item.title, - description: item.content, + description: `${item.member.username}: ${item.content_rendered}`, content: item.content, content_rendered: item.content_rendered, pubDate: new Date(item.created * 1000).toUTCString(), guid: item.id, link: item.url, + author: item.member.username, })), }; }; diff --git a/views/json.art b/views/json.art index b00efa07f0..89f34cc7f2 100644 --- a/views/json.art +++ b/views/json.art @@ -11,6 +11,9 @@ { "id": "{{ $value.guid || $value.link }}", "url": "{{ $value.link }}", + "author": { + "name": "{{ $value.author }}", + }, "external_url": "", "title": "{{ $value.title }}", "content_html": "{{ $value.content_rendered }}", diff --git a/views/rss.art b/views/rss.art index f57668ad59..a95c6c3131 100644 --- a/views/rss.art +++ b/views/rss.art @@ -20,10 +20,10 @@ <![CDATA[{{@ $value.title }}]]> - {{ if $value.pubDate }} - {{ $value.pubDate }}{{ /if }} + {{ if $value.pubDate }}{{ $value.pubDate }}{{ /if }} {{ $value.guid || $value.link }} {{ $value.link }} + {{ if $value.author }}{{ /if }} {{ /each }}