Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@moosesaeed/smartnews-feed
Advanced tools
Readme
Feed module enables everyone to have RSS, Atom and Json.
@nuxtjs/feed
dependency to your projectyarn add @nuxtjs/feed # or npm install @nuxtjs/feed
@nuxtjs/feed
to the modules
section of nuxt.config.js
export default {
modules: [
['@nuxtjs/feed', {
// Your feeds here
}]
]
}
export default {
modules: [
'@nuxtjs/feed'
],
feed: [
// Your feeds here
]
}
So... how to get these feeds working now?
export default {
feed: [
// A default feed configuration object
{
path: '/feed.xml', // The route to your feed.
async create(feed) {}, // The create function (see below)
cacheTime: 1000 * 60 * 15, // How long should the feed be cached
type: 'rss2', // Can be: rss2, atom1, json1
data: ['Some additional data'] // Will be passed as 2nd argument to `create` function
}
]
}
Let's take a closer look on the create
function. This is the API that
actually modifies your upcoming feed.
A simple create function could look like this:
import axios from 'axios'
// In your `feed` array's object:
async create (feed) {
feed.options = {
title: 'My blog',
link: 'https://lichter.io/feed.xml',
description: 'This is my personal feed!'
}
const posts = await (axios.get('https://blog-api.lichter.io/posts')).data
posts.forEach(post => {
feed.addItem({
title: post.title,
id: post.url,
link: post.url,
description: post.description,
content: post.content
})
})
feed.addCategory('Nuxt.js')
feed.addContributor({
name: 'Alexander Lichter',
email: 'example@lichter.io',
link: 'https://lichter.io/'
})
}
Feed creation is based on the feed package.
Please use it as reference and further documentation for modifying the feed
object
that is passed to the create
function.
Using the create
function gives you almost unlimited possibilities to customize your feed!
There is one more thing. Imagine you want to add a feed per blog category, but you don't want to add every category by hand.
You can use a factory function
to solve that problem. Instead of a hardcoded array, you can setup
a function that will be called up on feed generation. The function must return an array with all
feeds you want to generate.
export default {
feed: async () => {
const posts = (await axios.get('https://blog-api.lichter.io/posts')).data
const tags = (await axios.get('https://blog-api.lichter.io/tags')).data
return tags.map(t => {
const relevantPosts = posts.filter(/*filter posts somehow*/)
return {
path: `/${t.slug}.xml`, // The route to your feed.
async create(feed) {
feed.options = {
title: `${t.name} - My blog`,
link: `https://blog.lichter.io/${t.slug}.xml`,
description: `All posts related to ${t.name} of my blog`
}
relevantPosts.forEach(post => {
feed.addItem({
title: post.title,
id: post.id,
link: `https://blog.lichter.io/posts/${post.slug}`,
description: post.excerpt,
content: post.text
})
})
},
cacheTime: 1000 * 60 * 15,
type: 'rss2'
}
})
}
}
In case you want to pass in data into the factory function, you can use a factory object.
export default {
feed: {
data: ['Your data here'],
factory: (dataFromFeedDotData) => {/* your factory function */}
}
}
yarn install
or npm install
npm run dev
Copyright (c) - Nuxt Community
FAQs
Feed module customized for Google Cloud Functions.
The npm package @moosesaeed/smartnews-feed receives a total of 28 weekly downloads. As such, @moosesaeed/smartnews-feed popularity was classified as not popular.
We found that @moosesaeed/smartnews-feed demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.