diff --git a/Makefile b/Makefile index 17ab607e14..adaed6f1e7 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ blogclean: rm -rf out/blog blog: doc/blog out/Release/node tools/blog - out/Release/node tools/blog/generate.js doc/blog/ out/blog/ doc/blog.html + out/Release/node tools/blog/generate.js doc/blog/ out/blog/ doc/blog.html doc/rss.xml $(apidoc_dirs): mkdir -p $@ diff --git a/doc/rss.xml b/doc/rss.xml new file mode 100644 index 0000000000..a96aa78f72 --- /dev/null +++ b/doc/rss.xml @@ -0,0 +1,45 @@ + + + + + Node.js Blog + + http://blog.nodejs.org/ + The Blog about Node.js + <%= new Date().toUTCString() %> + en + weekly + 1 + http://nodejs.org/ + + http://nodejs.org/images/logo-light.png + Node.js + http://blog.nodejs.org/ + + <% + posts.forEach(function(post) { + %> + + <%= post.title %> + http://blog.nodejs.org<%= post.permalink %> + <%= post.date.toUTCString() %> + <%= post.author %> + ]]> + + http://blog.nodejs.org<%= post.permalink %> + ]]> + ]]> + + <% + }); + %> + + diff --git a/tools/blog/generate.js b/tools/blog/generate.js index b7e8629f43..a9c69b56ad 100644 --- a/tools/blog/generate.js +++ b/tools/blog/generate.js @@ -10,6 +10,7 @@ var semver = require('semver'); var input = path.resolve(process.argv[2]); var output = path.resolve(process.argv[3]); var template = path.resolve(process.argv[4]); +var rssTemplate = path.resolve(process.argv[5]); var config = { postsPerPage: 4 @@ -20,7 +21,13 @@ console.error("argv=%j", process.argv) fs.readFile(template, 'utf8', function(er, contents) { if (er) throw er; template = ejs.compile(contents, template); - readInput(); + template.filename = 'index.html'; + fs.readFile(rssTemplate, 'utf8', function(er, contents) { + if (er) throw er; + rssTemplate = ejs.compile(contents, rssTemplate); + rssTemplate.filename = 'index.xml'; + readInput(); + }); }); function readInput() { @@ -101,14 +108,15 @@ function buildPermalink(key, post) { return data; } -function writeFile(uri, data) { +function writeFile(uri, data, templ) { + if (!templ) templ = template; data.uri = path.join(data.uri); uri = path.join(uri); - var contents = template(data); + var contents = templ(data); var outdir = path.join(output, uri); mkdirp(outdir, function(er) { if (er) throw er; - var file = path.resolve(outdir, 'index.html'); + var file = path.resolve(outdir, templ.filename); fs.writeFile(file, contents, 'utf8', function(er) { if (er) throw er; console.log('wrote: ', data.pageid, path.relative(process.cwd(), file)); @@ -248,8 +256,10 @@ function writePaginated(title, posts, p, total, id) { }; if (p === 0) { writeFile(uri, d); + writeFile('/feed' + uri, d, rssTemplate); } writeFile(uri + p, d); + writeFile('/feed' + uri + p, d, rssTemplate); } function buildOutput(data) {