62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
const htmlmin = require('html-minifier');
|
|
const dateFns = require('date-fns');
|
|
const lazyImagesPlugin = require('eleventy-plugin-lazyimages');
|
|
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
|
|
|
|
module.exports = function (eleventyConfig) {
|
|
eleventyConfig.addPlugin(syntaxHighlight);
|
|
|
|
eleventyConfig.addPlugin(lazyImagesPlugin, {
|
|
transformImgPath: (imgPath) => {
|
|
if (imgPath.startsWith('http://') || imgPath.startsWith('https://')) {
|
|
// Handle remote file
|
|
return imgPath;
|
|
} else {
|
|
return `./src/${imgPath}`;
|
|
}
|
|
},
|
|
});
|
|
|
|
eleventyConfig.setEjsOptions({
|
|
rmWhitespace: true,
|
|
context: {
|
|
dateFns,
|
|
},
|
|
});
|
|
|
|
eleventyConfig.setBrowserSyncConfig({
|
|
files: './_site/assets/styles/main.css',
|
|
});
|
|
|
|
eleventyConfig.addPassthroughCopy("styles/fonts");
|
|
|
|
eleventyConfig.addTransform('htmlmin', (content, outputPath) => {
|
|
if (outputPath.endsWith('.html')) {
|
|
const minified = htmlmin.minify(content, {
|
|
useShortDoctype: true,
|
|
removeComments: true,
|
|
collapseWhitespace: true,
|
|
minifyJS: true,
|
|
});
|
|
return minified;
|
|
}
|
|
|
|
return content;
|
|
});
|
|
|
|
// Import fast-glob package
|
|
const fg = require('fast-glob');
|
|
|
|
// Run search for images in /gallery and /sponsors
|
|
const galleryImages = fg.sync(['**/images/screenshots/*', '!**/_site']);
|
|
console.log(galleryImages);
|
|
|
|
//Create collection of sponsor logos
|
|
eleventyConfig.addCollection('screenshots', function(collection) {
|
|
return galleryImages;
|
|
});
|
|
|
|
return {
|
|
dir: { input: 'src', output: '_site', data: '_data' },
|
|
};
|
|
};
|