Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import http from 'http'
import { Feed } from 'feed'
import data from './_posts/_data.json'
import { readFileSync } from 'fs'
import fm from 'front-matter'
import marked from 'marked'
const feed = new Feed({
title: 'CopenhagenJS',
description: 'A monthly meetup about JavaScript in Copenhagen',
id: 'https://copenhagenjs.dk/',
link: 'https://copenhagenjs.dk/',
language: 'en', // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
image: 'https://copenhagenjs.dk/static/images/cphjs.png',
favicon: 'https://copenhagenjs.dk/static/images/cphjs.png',
generator: '' // optional, default = 'Feed for Node.js'
})
data.posts.forEach(post => {
const markdown = readFileSync('./_posts/' + post, 'utf8')
const parsed = fm(markdown)
const date = parsed.attributes.date
? new Date(parsed.attributes.date + ' GMT+0200')
: new Date(
async function renderRSSFeed({ routes }) {
let publicURL = process.env.PUBLIC_URL || '/'
let { paths } = await crawl({
routes,
root: '/posts',
})
const feed = new Feed({
title: siteMetadata.title,
description: siteMetadata.description,
id: publicURL,
// TODO: set this based on the siteMap slugs
// updated: new Date(),
link: publicURL,
author: {
name: siteMetadata.author,
},
});
for (let pathname of paths.sort()) {
let route = await resolve({
routes,
url: pathname,
})
res.status(400).json(errors);
}
const queryString = querystring.stringify(query, '&'); // Use & for XML meta tags
const feedOption = {
title: (query.q ? `${query.q} | ` : '') + t`Cofacts reported messages`,
link: `${PUBLIC_URL}/articles?${queryString}`,
description: t`List of messages reported by Cofacts users`,
feedLinks: {
json: `${PUBLIC_URL}/api/articles/json1?${queryString}`,
rss: `${PUBLIC_URL}/api/articles/rss2?${queryString}`,
atom: `${PUBLIC_URL}/api/articles/atom1?${queryString}`,
},
};
const feedInstance = new Feed(feedOption);
data.ListArticles.edges.forEach(({ node }) => {
const text = getArticleText(node);
const url = `${PUBLIC_URL}/article/${node.id}`;
feedInstance.addItem({
id: url,
title: ellipsis(text, { wordCount: TITLE_LENGTH }),
// https://stackoverflow.com/a/54905457/1582110
description: text,
link: url,
date: new Date(node.createdAt),
image: getImage(node),
});
});
'thread_score': tweet.thread_score,
'thread_length': tweet.thread_length,
'retweet_count_combined': tweet.retweet_count_combined,
'favorite_count_combined': tweet.favorite_count_combined,
}
filteredOutput.tweets.push(outputTweet)
}
fs.writeFileSync('thread-list.json', 'const data = ' + JSON.stringify(filteredOutput, null, 2), 'utf8')
// Generate RSS (Atom) feed
// -----------------------------------------
const feed = new Feed({
title: `${filteredOutput.account.accountDisplayName}’s Twitter threads`,
description: `An automatically-generated list of Twitter threads from @${filteredOutput.account.username}`,
generator: 'https://github.com/mwichary/twitter-thread-list',
})
for (let i in threadTweetsSortedByLastUpdatedDate) {
const tweet = threadTweetsSortedByLastUpdatedDate[i]
feed.addItem({
title: tweet.full_text,
content: `Thread with ${tweet.thread_length} tweets. ` +
`Created on ${new Date(tweet.created_at).toDateString()}, last updated on ${new Date(tweet.last_updated_at).toDateString()}.`,
link: `https://twitter.com/${filteredOutput.account.username}/status/${tweet.id_str}`,
date: new Date(tweet.last_updated_at)
})
}
async buildFeed() {
const DEFAULT_FEED_COUNT = 10
const feedFilename = 'atom.xml'
const { themeConfig } = this.db
const feed = new Feed({
title: themeConfig.siteName,
description: themeConfig.siteDescription,
id: themeConfig.domain,
link: themeConfig.domain,
image: urlJoin(themeConfig.domain, 'images', 'avatar.png'),
favicon: urlJoin(themeConfig.domain, 'favicon.ico'),
copyright: `All rights reserved ${(new Date()).getFullYear()}, ${themeConfig.siteName}`,
feedLinks: {
atom: urlJoin(themeConfig.domain, feedFilename),
},
})
const postsData = this.postsData
.filter((item: IPostRenderData) => !item.hideInList)
.slice(0, themeConfig.feedCount || DEFAULT_FEED_COUNT)
if (body.size) {
size = Math.min(parseInt(body.size, 10), size);
}
const litems = ['l_rss_title', 'l_rss_description',
'l_rss_id', 'l_rss_link', 'l_rss_copyright', 'l_p_action'];
const lang_items = await Promise.all(litems.map(l =>
LangUtils.get_language_values_from_langs(l, [{ value: lang }])));
const langs_object = lang_items.reduce((obj, items) => {
if (items.length > 0) {
obj[items[0].key] = items[0].value;
}
return obj;
}, {});
const feed = new Feed({
title: langs_object.l_rss_title || 'l_rss_title',
description: langs_object.l_rss_description || 'l_rss_description',
id: langs_object.l_rss_id || 'l_rss_id',
link: langs_object.l_rss_link || 'l_rss_link',
copyright: langs_object.l_rss_copyright || 'l_rss_copyright',
generator: 'PolarisOS',
});
const items = await EntitiesUtils.search_and_get_sources(entity, {
size,
sort,
where: query,
});
items.forEach((item) => {
feed.addItem({
import { Feed } from "feed"
import GitFile from './classes/GitFile'
const max = (among, attr) => new Date(Math.max(...among.map(item => attr(item))))
const emptyFeed = new Feed({
title: 'The best books for developers – mustread.tech',
description: "Open-source and crowd-sourced book listing",
link: "http://mustread.tech",
id: "http://static.mustread.tech/rss.xml",
author: {
name: "Eduards Sizovs"
},
})
module.exports = books =>
Promise
.all(books
.map(book =>
new GitFile(book.location)
.revs()
.then(([firstRev]) => {
const buildFeed = (database, siteConfig, lang, isAtom = false) => {
const prefix = lang === siteConfig.defaultLocale ? "" : `/${lang}`;
const baseUrl = `${siteConfig.baseUrl}${prefix}`;
const feed = new Feed({
title: siteConfig.title,
description: siteConfig.description,
id: baseUrl,
link: baseUrl,
updated: new Date(),
generator: "Statusfy",
feedLinks: {
atom: `${siteConfig.baseUrl}/feeds/incidents.${lang}.${
isAtom ? "atom" : "xml"
}`
}
});
const { incidents } = database.incidents(lang, 1, -1);
incidents.forEach(incident => {
}, Promise.resolve()).then(function() {
let articles = g_articles.filter(function(article) {
return article.dateAdded !== undefined;
});
articles = articles.sort(function(a, b) {
return b.dateAdded - a.dateAdded;
});
if (articles.length) {
const feed = new Feed({
title: g_langInfo.title,
description: g_langInfo.description,
link: g_langInfo.link,
image: `${settings.baseUrl}/${settings.rootFolder}/lessons/resources/${settings.siteThumbnail}`,
date: articles[0].dateModified.toDate(),
published: articles[0].dateModified.toDate(),
updated: articles[0].dateModified.toDate(),
author: {
name: `${settings.siteName} Contributors`,
link: `${settings.baseUrl}/contributors.html`,
},
});
articles.forEach(function(article) {
feed.addItem({
title: article.title,