@nuxtjs/feed
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/nuxt-community/feed-module/compare/v0.1.1...v0.2.0) (2018-10-05) | ||
### Bug Fixes | ||
* fix typo in package.json ([ff69039](https://github.com/nuxt-community/feed-module/commit/ff69039)) | ||
### Features | ||
* set default generator to nuxt-feed module ([2cfc35b](https://github.com/nuxt-community/feed-module/commit/2cfc35b)) | ||
<a name="0.1.1"></a> | ||
@@ -7,0 +22,0 @@ ## [0.1.1](https://github.com/nuxt-community/feed-module/compare/v0.1.0...v0.1.1) (2018-04-20) |
@@ -1,7 +0,7 @@ | ||
const path = require('path') | ||
const fs = require('fs-extra') | ||
const AsyncCache = require('async-cache') | ||
const pify = require('pify') | ||
const Feed = require('feed') | ||
const consola = require('consola') | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import AsyncCache from 'async-cache' | ||
import pify from 'pify' | ||
import { Feed } from 'feed' | ||
import consola from 'consola' | ||
@@ -16,3 +16,3 @@ const logger = consola.withScope('nuxt:feed') | ||
module.exports = async function feed () { | ||
export default async function feed () { | ||
if (typeof this.options.feed === 'function') { | ||
@@ -29,5 +29,4 @@ this.options.feed = await this.options.feed() | ||
const feedCache = new AsyncCache({ | ||
maxAge: options.cacheTime, | ||
load (feedIndex, callback) { | ||
createFeed(options[feedIndex], callback) | ||
createFeed(options[feedIndex], callback).catch(err => /* istanbul ignore next */ logger.error(err)) | ||
} | ||
@@ -38,3 +37,3 @@ }) | ||
await options.forEach(async (feedOptions, index) => { | ||
options.forEach((feedOptions, index) => { | ||
this.nuxt.hook('generate:before', async () => { | ||
@@ -48,9 +47,10 @@ const xmlGeneratePath = path.resolve(this.options.srcDir, path.join('static', feedOptions.path)) | ||
path: feedOptions.path, | ||
handler (req, res, next) { | ||
feedCache.get(index) | ||
.then(xml => { | ||
res.setHeader('Content-Type', resolveContentType(feedOptions.type)) | ||
res.end(xml) | ||
}) | ||
.catch(/* istanbul ignore next: Nuxt handling */ err => { next(err) }) | ||
async handler (req, res, next) { | ||
try { | ||
const xml = await feedCache.get(index) | ||
res.setHeader('Content-Type', resolveContentType(feedOptions.type)) | ||
res.end(xml) | ||
} catch (err) /* istanbul ignore next */ { | ||
next(err) | ||
} | ||
} | ||
@@ -77,3 +77,9 @@ }) | ||
const feed = new Feed() | ||
await feedOptions.create.call(this, feed) | ||
try { | ||
await feedOptions.create.call(this, feed) | ||
feed.options = Object.assign({ generator: 'https://github.com/nuxt-community/feed-module' }, feed.options) | ||
} catch (err) /* istanbul ignore next */ { | ||
logger.fatal('Error while executing feed creation function') | ||
logger.error(err) | ||
} | ||
return callback(null, feed[feedOptions.type](), feedOptions.cacheTime) | ||
@@ -80,0 +86,0 @@ } |
{ | ||
"name": "@nuxtjs/feed", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/nuxt-community/feed-moduleissues" | ||
"url": "https://github.com/nuxt-community/feed-module/issues" | ||
}, | ||
@@ -60,24 +60,25 @@ "publishConfig": { | ||
"async-cache": "^1.1.0", | ||
"consola": "^1.2.0", | ||
"feed": "^1.1.1", | ||
"fs-extra": "latest", | ||
"consola": "^1.4.3", | ||
"feed": "^2.0.1", | ||
"fs-extra": "^7.0.0", | ||
"pify": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^6.1.3", | ||
"@commitlint/config-conventional": "^6.1.3", | ||
"codecov": "latest", | ||
"eslint": "latest", | ||
"eslint-config-standard": "latest", | ||
"eslint-plugin-import": "latest", | ||
"eslint-plugin-jest": "latest", | ||
"eslint-plugin-node": "latest", | ||
"eslint-plugin-promise": "latest", | ||
"eslint-plugin-standard": "latest", | ||
"eslint-plugin-vue": "latest", | ||
"husky": "^1.0.0-rc.1", | ||
"jest": "latest", | ||
"jsdom": "latest", | ||
"nuxt": "latest", | ||
"standard-version": "latest" | ||
"@commitlint/cli": "^7.1.2", | ||
"@commitlint/config-conventional": "^7.1.2", | ||
"codecov": "^3.1.0", | ||
"eslint": "^5.6.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jest": "^21.24.1", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"eslint-plugin-vue": "^4.7.1", | ||
"husky": "^1.1.0", | ||
"jest": "^23.6.0", | ||
"jsdom": "^12.1.0", | ||
"nuxt": "^2.1.0", | ||
"request-promise-native": "^1.0.5", | ||
"standard-version": "^4.4.0" | ||
}, | ||
@@ -84,0 +85,0 @@ "husky": { |
@@ -69,20 +69,26 @@ # Feed module - Everyone deserves RSS, Atom and Json | ||
```js | ||
create = async feed => { | ||
//Import axios into your nuxt.config.js | ||
const axios = require('axios') | ||
// In your `feed` array: | ||
async create (feed) { | ||
feed.options = { | ||
title: 'My blog', | ||
link: 'https://my-url.com/feed.xml', | ||
description: 'This is my personal feed!', | ||
} | ||
const posts = await axios.get('https://blog.lichter.io/posts/').data | ||
posts.forEach(post => { | ||
const posts = await (axios.get('https://api.blog.lichter.io/posts')).data | ||
posts.forEach(post => { | ||
feed.addItem({ | ||
title: post.title, | ||
id: post.url, | ||
link: post.url, | ||
description: post.description, | ||
content: post.content | ||
title: post.title, | ||
id: post.url, | ||
link: post.url, | ||
description: post.description, | ||
content: post.content | ||
}) | ||
}) | ||
feed.addCategory('Nuxt.js') | ||
feed.addContributor({ | ||
@@ -114,4 +120,4 @@ name: 'Alexander Lichter', | ||
feed: async () => { | ||
const posts = (await axios.get('https://my-url.com/posts')).data | ||
const tags = (await axios.get('https://my-url.com/tags')).data | ||
const posts = (await axios.get('https://api.blog.lichter.io/posts')).data | ||
const tags = (await axios.get('https://api.blog.lichter.io/tags')).data | ||
@@ -126,2 +132,3 @@ return tags.map(t => { | ||
title: `${t.name} - My blog`, | ||
link: `https://my-url.com/${t.slug}.xml`, | ||
description: `All posts related to ${t.name} of my blog`, | ||
@@ -128,0 +135,0 @@ } |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
11296
70
0
164
17
+ Addedfeed@2.0.4(transitive)
+ Addedfs-extra@7.0.1(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedluxon@1.28.1(transitive)
+ Addeduniversalify@0.1.2(transitive)
- Removedfeed@1.1.1(transitive)
- Removedfs-extra@11.3.0(transitive)
- Removedjsonfile@6.1.0(transitive)
- Removeduniversalify@2.0.1(transitive)
Updatedconsola@^1.4.3
Updatedfeed@^2.0.1
Updatedfs-extra@^7.0.0