gatsby-plugin-feed
Advanced tools
Comparing version 1.0.0-alpha.22 to 1.0.0-alpha.23
{ | ||
"name": "gatsby-plugin-feed", | ||
"version": "1.0.0-alpha.22", | ||
"version": "1.0.0-alpha.23", | ||
"description": "Creates an RSS feed for your Gatsby site.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,18 +0,18 @@ | ||
import path from 'path' | ||
import { defaultOptions, runQuery, writeFile } from './internals' | ||
import path from "path" | ||
import RSS from "RSS" | ||
import { defaultOptions, runQuery, writeFile } from "./internals" | ||
const publicPath = './public' | ||
const publicPath = `./public` | ||
// A default function to transform query data into feed entries. | ||
const serialize = ({ site, allMarkdownRemark }) => ( | ||
allMarkdownRemark.edges.map(edge => ({ | ||
...edge.node.frontmatter, | ||
description: edge.node.excerpt, | ||
url: site.siteMetadata.site_url + edge.node.fields.slug, | ||
guid: site.siteMetadata.site_url + edge.node.fields.slug, | ||
custom_elements: [ | ||
{ 'content:encoded': edge.node.html } | ||
] | ||
})) | ||
) | ||
const serialize = ({ site, allMarkdownRemark }) => | ||
allMarkdownRemark.edges.map(edge => { | ||
return { | ||
...edge.node.frontmatter, | ||
description: edge.node.excerpt, | ||
url: site.siteMetadata.site_url + edge.node.fields.slug, | ||
guid: site.siteMetadata.site_url + edge.node.fields.slug, | ||
custom_elements: [{ "content:encoded": edge.node.html }], | ||
} | ||
}) | ||
@@ -41,3 +41,3 @@ exports.onPostBuild = async ({ graphql }, pluginOptions) => { | ||
const ctx = { ...globals, ...locals } | ||
const feed = setup({ ...rest, ...ctx }) | ||
const feed = new RSS(setup({ ...rest, ...ctx })) | ||
const items = f.serialize ? f.serialize(ctx) : serialize(ctx) | ||
@@ -44,0 +44,0 @@ |
@@ -1,3 +0,3 @@ | ||
import React from 'react' | ||
import { defaultOptions } from './internals' | ||
import React from "react" | ||
import { defaultOptions } from "./internals" | ||
@@ -11,13 +11,7 @@ exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => { | ||
const links = feeds.map(({ output }) => { | ||
if (output.charAt(0) !== '/') { | ||
output = '/' + output | ||
if (output.charAt(0) !== `/`) { | ||
output = `/` + output | ||
} | ||
return ( | ||
<link | ||
rel="alternate" | ||
type="application/rss+xml" | ||
href={output} | ||
/> | ||
) | ||
return <link rel="alternate" type="application/rss+xml" href={output} /> | ||
}) | ||
@@ -27,2 +21,1 @@ | ||
} | ||
@@ -1,11 +0,10 @@ | ||
import fs from 'fs' | ||
import RSS from 'rss' | ||
import pify from 'pify' | ||
import fs from "fs" | ||
import pify from "pify" | ||
export const writeFile = pify(fs.writeFile) | ||
export const runQuery = (handler, query) => handler(query) | ||
.then(r => { | ||
export const runQuery = (handler, query) => | ||
handler(query).then(r => { | ||
if (r.errors) { | ||
throw new Error(r.errors.join(', ')) | ||
throw new Error(r.errors.join(`, `)) | ||
} | ||
@@ -34,7 +33,11 @@ | ||
// Setup a few RSS object, merging on various feed-speciupfic options. | ||
setup: ({ site: { siteMetadata }, ...rest }) => new RSS({ ...siteMetadata, ...rest }), | ||
setup: ({ site: { siteMetadata }, ...rest }) => {return ({ | ||
...siteMetadata, | ||
...rest, | ||
})}, | ||
// Create a default RSS feed. Others may be added by using the format below. | ||
feeds: [{ | ||
query: ` | ||
feeds: [ | ||
{ | ||
query: ` | ||
{ | ||
@@ -68,5 +71,6 @@ allMarkdownRemark( | ||
// Where we will save the feed generated by this query. | ||
output: `rss.xml`, | ||
}] | ||
// Where we will save the feed generated by this query. | ||
output: `rss.xml`, | ||
}, | ||
], | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
5369
7
122
1