Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
feat(Feed): added
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Jun 5, 2017
1 parent 42f6935 commit 70c1f84
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const striptags = str => str.replace(/<[^>]+>/g, '')
// This renders a page
const buildPage = (build, config, collections, blocks, content, identifier, template, includesFiles, translatedStrings) => {
const isIndex = identifier === 'index'
const isFeed = identifier === 'feed'
const page = {
url: config.webHost + config.baseHref + (isIndex ? '' : identifier) + '/'
}
Expand Down Expand Up @@ -151,6 +152,9 @@ const buildPage = (build, config, collections, blocks, content, identifier, temp
if (isIndex) {
writeFileSync(`build/${identifier}.html`, pageTemplate)
console.log(`build/${identifier}.html`)
} else if (isFeed) {
writeFileSync(`build/${identifier}.xml`, pageTemplate)
console.log(`build/${identifier}.xml`)
} else {
const dir = `build/${identifier}/`
if (!existsSync(dir)) mkdirSync(dir)
Expand Down Expand Up @@ -236,5 +240,8 @@ export const buildSite = (contentFile, templateDir, version, locale, environment

// Archive
buildPage(build, config, collections, blocks, {posts}, 'archive', path.join(templateDir, '/archive.html'), includesFiles, translatedStrings)

// feed.xml
buildPage(build, config, collections, blocks, {posts}, 'feed', path.join(templateDir, '/feed.xml'), includesFiles, translatedStrings)
}

0 comments on commit 70c1f84

Please sign in to comment.