gitbook-plugin-rss
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -8,3 +8,3 @@ require([ 'gitbook' ], function (gitbook) { | ||
onClick: function () { | ||
window.open(config.rss.site_url + '/rss.xml'); | ||
window.open(config.rss.feed_url); | ||
} | ||
@@ -11,0 +11,0 @@ }); |
@@ -23,2 +23,4 @@ 'use strict'; | ||
var _url = require('url'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -33,3 +35,8 @@ | ||
assets: './assets', | ||
js: ['plugin.js'] | ||
js: ['plugin.js'], | ||
html: { | ||
'head:end': function headEnd() { | ||
return '<link href="' + site.feed_url + '" title="' + site.title + '" rel="alternate"type="application/rss+xml">'; | ||
} | ||
} | ||
}, | ||
@@ -62,3 +69,4 @@ | ||
var xml = feed.xml({ indent: true }); | ||
(0, _fs.writeFileSync)((0, _path.resolve)(this.options.output, 'rss.xml'), xml, 'utf-8'); | ||
var feedpath = (0, _path.basename)((0, _url.parse)(site.feed_url).pathname); | ||
(0, _fs.writeFileSync)((0, _path.resolve)(this.options.output, feedpath), xml, 'utf-8'); | ||
} | ||
@@ -65,0 +73,0 @@ } |
11
index.js
@@ -5,3 +5,4 @@ import title from 'get-md-title'; | ||
import { writeFileSync as write } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { resolve, basename } from 'path'; | ||
import { parse } from 'url'; | ||
@@ -14,3 +15,6 @@ // Define variables | ||
assets: './assets', | ||
js: [ 'plugin.js' ] | ||
js: [ 'plugin.js' ], | ||
html: { | ||
'head:end': () => `<link href="${site.feed_url}" title="${site.title}" rel="alternate"type="application/rss+xml">` | ||
} | ||
}, | ||
@@ -46,5 +50,6 @@ | ||
const xml = feed.xml({ indent: true }); | ||
write(resolve(this.options.output, 'rss.xml'), xml, 'utf-8'); | ||
const feedpath = basename(parse(site.feed_url).pathname); | ||
write(resolve(this.options.output, feedpath), xml, 'utf-8'); | ||
} | ||
} | ||
}; |
{ | ||
"name": "gitbook-plugin-rss", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "RSS for your gitbook", | ||
@@ -29,2 +29,7 @@ "main": "index.es5.js", | ||
}, | ||
"feed_url": { | ||
"type": "string", | ||
"required": true, | ||
"description": "Url to the rss feed." | ||
}, | ||
"image_url": { | ||
@@ -31,0 +36,0 @@ "type": "string", |
@@ -47,2 +47,3 @@ # gitbook-plugin-rss | ||
* `site_url` (_required_ **url string**) — Url to the site that the feed is for. | ||
* `feed_url` (_required_ **url string**) — Url to the rss feed. | ||
* `description` (_optional_ **string**) — A short description of the feed. | ||
@@ -49,0 +50,0 @@ * `generator` (_optional_ **string**) — Feed generator. |
8936
111
66