diff --git a/build/production/__snapshots__/write-tree.test.js.snap b/build/production/__snapshots__/write-tree.test.js.snap index b7a1e01..220dbcc 100644 --- a/build/production/__snapshots__/write-tree.test.js.snap +++ b/build/production/__snapshots__/write-tree.test.js.snap @@ -85,6 +85,12 @@ Thank you! I built it using [VuePress](https://vuepress.vuejs.org/). I liked the " `; +exports[`write-tree no categories should write the netlify _headers file 1`] = ` +"/* + Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; +" +`; + exports[`write-tree one category, no page with image should write a category/readme.md file using the category template 1`] = ` "# Category diff --git a/build/production/templates/.vuepress/public/_headers.handlebars b/build/production/templates/.vuepress/public/_headers.handlebars new file mode 100644 index 0000000..9215f40 --- /dev/null +++ b/build/production/templates/.vuepress/public/_headers.handlebars @@ -0,0 +1,2 @@ +/* + Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; diff --git a/build/production/write-tree.js b/build/production/write-tree.js index c211557..dcfa7fa 100644 --- a/build/production/write-tree.js +++ b/build/production/write-tree.js @@ -22,6 +22,10 @@ module.exports = (defaults, destinationPath) => { fs.copyFileSync('./templates/.vuepress/styles/index.styl', `${destinationPath}/.vuepress/styles/index.styl`) fs.copyFileSync('./templates/.vuepress/styles/palette.styl', `${destinationPath}/.vuepress/styles/palette.styl`) + const netlifyHeadersTemplate = fs.readFileSync('./templates/.vuepress/public/_headers.handlebars', 'utf8') + const netlifyHeadersContent = Handlebars.compile(netlifyHeadersTemplate)() + fs.writeFileSync(`${destinationPath}/.vuepress/public/_headers`, netlifyHeadersContent) + const homeTemplate = fs.readFileSync('./templates/home.md.handlebars', 'utf8') const rootReadmeContent = Handlebars.compile(homeTemplate)(defaults) fs.writeFileSync(`${destinationPath}/readme.md`, rootReadmeContent) diff --git a/build/production/write-tree.test.js b/build/production/write-tree.test.js index 996fe9c..672196c 100644 --- a/build/production/write-tree.test.js +++ b/build/production/write-tree.test.js @@ -36,6 +36,11 @@ describe('write-tree', () => { }) }) + it('should write the netlify _headers file', () => { + const netlifyHeadersContent = readFile(`${destinationPath}/.vuepress/public/_headers`) + expect(netlifyHeadersContent).toMatchSnapshot() + }) + it('should write an empty readme.md file using the home template', () => { const rootReadmeContent = readFile(`${destinationPath}/readme.md`) expect(rootReadmeContent).toMatchSnapshot()