diff --git a/eleventy.config.js b/eleventy.config.js index 5ce258c..41dc78d 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -9,86 +9,107 @@ const IMAGE_SIZES = [300, 600, 900, 1200] module.exports = function(eleventyConfig) { - // https://www.11ty.dev/docs/data-deep-merge/ - eleventyConfig.setDataDeepMerge(true) + // https://www.11ty.dev/docs/data-deep-merge/ + eleventyConfig.setDataDeepMerge(true) - // https://www.11ty.dev/docs/plugins/image/#make-your-own-markup - eleventyConfig.addShortcode("image", async (src, alt) => { - const metadata = await pluginImage(`./_src${src}`, { - widths: [...IMAGE_SIZES, 'auto'], - formats: ['auto', 'webp', 'avif'], - // https://www.11ty.dev/docs/plugins/image/#custom-filenames - filenameFormat: (id, src, width, format) => - `${path.basename(src,path.extname(src))}-${width}w.${format}`, - // https://alexpeterhall.com/blog/2021/04/05/responsive-images-eleventy/#eleventy-configuration - urlPath: path.dirname(src), - outputDir: `_site/${path.dirname(src)}`, - }) + // Optimized images + // https://www.11ty.dev/docs/plugins/image/#make-your-own-markup + eleventyConfig.addShortcode('image', async (src, alt) => { + const metadata = await pluginImage(`./_src${src}`, { + widths: [...IMAGE_SIZES, 'auto'], + formats: ['auto', 'webp', 'avif'], + // https://www.11ty.dev/docs/plugins/image/#custom-filenames + filenameFormat: (id, src, width, format) => + `${path.basename(src,path.extname(src))}-${width}w.${format}`, + // https://alexpeterhall.com/blog/2021/04/05/responsive-images-eleventy/#eleventy-configuration + urlPath: path.dirname(src), + outputDir: `_site/${path.dirname(src)}`, + }) const lowsrc = metadata.webp[0] const highsrc = metadata.webp[metadata.webp.length - 1] - return `\n${Object.values(metadata).map(imageFormat => - `\t`).join("\n")}\n\t${alt}\n` + return `${Object.values(metadata).map(imageFormat => + `\t`).join('')}${alt}` }) - eleventyConfig.addFilter('readableDate', dateObj => { - return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('dd LLL yyyy') - }) + // Video embed + eleventyConfig.addShortcode('vid', (src, autoplay=false) => + `` + ) + eleventyConfig.addShortcode('vidraw', (src) => + `` + ) - // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string - eleventyConfig.addFilter('htmlDateString', (dateObj) => { - return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd') - }) + // YouTube + eleventyConfig.addShortcode('yt', (shortcode) => + `` + ) - // Get the first `n` elements of a collection. - eleventyConfig.addFilter('head', (array, n) => { - if( n < 0 ) { - return array.slice(n) - } - return array.slice(0, n) - }) + // Audio embed + eleventyConfig.addShortcode('audio', (src, fmt) => + `` + ) + + // iFrame + eleventyConfig.addShortcode('iframe', (url, height) => + `