slime-quest-web/eleventy.config.js

35 lines
1.4 KiB
JavaScript

/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
export default function(eleventyConfig) {
// Markdown and templates go in site-source. They will be converted to HTML.
eleventyConfig.setInputDirectory('site-source');
eleventyConfig.setOutputDirectory('slimequest');
eleventyConfig.setTemplateFormats('md,njk');
// Everything else goes in site-static. It just gets copied normally.
eleventyConfig.addPassthroughCopy({ 'site-static': '/' });
eleventyConfig.addWatchTarget('site-static/*.css');
// If you want these files to live at, e.g. "example.com/quest", then set pathPrefix to "quest".
const pathPrefix = 'slimequest';
// Convenience function for quest images
// example: {% image '1.jpg' %}
// Can also add alt text:
// example: {% image '2.jpg', 'slime dragon with sword piercing its heart' %}
eleventyConfig.addShortcode('image', (filename, alt) => {
return `<img src=/${pathPrefix}/${filename} alt="${alt}" title="${alt}">`
});
// Fix page sorting. By default this is by file created date? We want it to be by filename.
eleventyConfig.addCollection('pages', (collection) => {
const comparator = Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
const compareSlugs = (a, b) => comparator.compare(a.fileSlug, b.fileSlug);
return collection.getFilteredByTag('pages').sort(compareSlugs);
});
return {
markdownTemplateEngine: 'njk',
pathPrefix: pathPrefix,
}
}