From e2be85925d9c43f9a56dc4fd2767ca42d2acf2be Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 31 Jan 2019 07:14:06 -0600 Subject: [PATCH] Adds https://github.com/11ty/eleventy/issues/386 to default eleventy-base-blog config --- .eleventy.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.eleventy.js b/.eleventy.js index fa65db0..57436b3 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,4 +1,5 @@ const { DateTime } = require("luxon"); +const fs = require("fs"); const pluginRss = require("@11ty/eleventy-plugin-rss"); const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); @@ -50,6 +51,20 @@ module.exports = function(eleventyConfig) { .use(markdownItAnchor, opts) ); + eleventyConfig.setBrowserSyncConfig({ + callbacks: { + ready: function(err, browserSync) { + const content_404 = fs.readFileSync('_site/404.html'); + + browserSync.addMiddleware("*", (req, res) => { + // Provides the 404 content without redirect. + res.write(content_404); + res.end(); + }); + } + } + }); + return { templateFormats: [ "md",