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",