Introduce renderers directory

This commit is contained in:
Akihiko Odaki 2018-04-02 13:41:25 +09:00
parent ad38cd2605
commit 4ef3d3a6d2
14 changed files with 14 additions and 14 deletions

View file

@ -0,0 +1,45 @@
/**
* 稿
* @param {*} post 稿
*/
const summarize = (post: any): string => {
let summary = '';
// チャンネル
summary += post.channel ? `${post.channel.title}:` : '';
// 本文
summary += post.text ? post.text : '';
// メディアが添付されているとき
if (post.media) {
summary += ` (${post.media.length}つのメディア)`;
}
// 投票が添付されているとき
if (post.poll) {
summary += ' (投票)';
}
// 返信のとき
if (post.replyId) {
if (post.reply) {
summary += ` RE: ${summarize(post.reply)}`;
} else {
summary += ' RE: ...';
}
}
// Repostのとき
if (post.repostId) {
if (post.repost) {
summary += ` RP: ${summarize(post.repost)}`;
} else {
summary += ' RP: ...';
}
}
return summary.trim();
};
export default summarize;