Browse Source

use excerpt or strip tags

excerpt
Alexander Yakovlev 3 years ago
parent
commit
ddc0bac972
  1. 12
      app/models/feed-data.js

12
app/models/feed-data.js

@ -6,6 +6,7 @@ const Core = require("../../core");
const DiscordUtil = require("../../core").util;
const GetUrls = require("get-urls");
const Url = require("url");
const striptags = require("striptags");
// @ts-ignore
const readFeed = url => promisify(require("rss-parser").parseURL)(url);
@ -109,9 +110,18 @@ module.exports = class FeedData extends Core.BaseEmbeddedData {
function formatPost(article) {
let message = "";
let excerpt = "";
if (article.title) message += `\n**${article.title}**`;
if (article.content) message += article.content.length > Config.charLimit ? "" : `\n${article.content}`;
if (article.contentSnippet) {
excerpt = striptags(article.contentSnippet);
}
else if (article.content) {
excerpt = striptags(article.content);
};
if (excerpt.length <= Config.charLimit) {
message += `\n${article.content}`
}
if (article.link) message += `\n\n${normaliseUrlForDiscord(article.link)}`;
return message;

Loading…
Cancel
Save