Files
camping-des-speakers-2022/.eleventy.js
Horacio Gonzalez ac00093947 Opening the CFP
2021-12-07 15:22:25 +01:00

97 lines
2.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file Configures preferences for Eleventy
* @author Reuben L. Lillie <reubenlillie@gmail.com>
* @author Horacio Gonzalez <horacio.gonzalez@gmail.com>
* @see {@link https://www.11ty.dev/docs/config/ 11ty Documentation}
*/
// Require native Node.js modules
import { readFileSync } from 'fs';
/**
* Require the includes module for the following.
*
* - Filters (for modifying content on input)
* - Shortcodes (for reusable content)
* - Transforms (for modifying a templates output)
*
* Storing these modules in separate directories,
* rather than all in this file,
* helps keep the codebase organized—at least thats the idea.
*/
import includes from './_includes/';
/**
* 11tys configuration module
* @module .eleventy
* @param {Object} eleventyConfig 11tys Config API
* @return {Object} 11tys Config object optional
* @see {@link https://www.11ty.dev/docs/config/ Configuring 11ty}
*/
export default function (eleventyConfig) {
// Pass 11tys Conig object to the includes module (~/_includes)
includes(eleventyConfig)
/**
* Combine data in the Eleventy data cascade, rather than overwriting it
* @see {@link https://www.11ty.dev/docs/data-deep-merge/ Data deep merge in 11ty}
*/
eleventyConfig.setDataDeepMerge(true);
/**
* Copy static assets to the output directory
* @see {@link https://www.11ty.dev/docs/copy/ Passthrough copy in 11ty}
*/
eleventyConfig.addPassthroughCopy('css');
eleventyConfig.addPassthroughCopy('img');
eleventyConfig.addPassthroughCopy('CNAME');
/**
* Have Eleventy watch the following additional files for live browsersync
* @see @{@link https://www.11ty.dev/docs/config/#add-your-own-watch-targets Add your own watch targets in 11ty}
*/
eleventyConfig.addWatchTarget('./**/*.css');
eleventyConfig.addWatchTarget('./**/*.js');
eleventyConfig.addWatchTarget('./**/*.md');
eleventyConfig.addWatchTarget('./**/*.jpg');
eleventyConfig.addWatchTarget('./**/*.png');
/**
* Serve the rendered 404 page when using `eleventy --serve` locally
* @see {@link https://www.11ty.dev/docs/quicktips/not-found/#with-serve Adding a 404 page in 11ty}
*/
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: (err, bs) => {
bs.addMiddleware("*", (req, res) => {
const content_404 = readFileSync('_site/404.html');
// Provides the 404 content without redirect
res.write(content_404);
// Add 404 http status code in request header
// res.writeHead(404, { "Content-Type": "text/html" })
res.writeHead(404);
res.end();
})
}
}
})
// If you want to use an alternative file structure,
// then you can uncomment this return statement
// and change the values for one or more of these directories
// (defaults shown).
return {
dir: {
input: '.',
includes: '_includes',
data: '_data',
output: '_site'
},
pathPrefix: '/',
}
}