Skip to content

Commit 1eb6509

Browse files
committed
Fixed boid simulation
1 parent 9f7e01a commit 1eb6509

12 files changed

+190
-2554
lines changed

.eleventy.js

+31-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
// This plugin automatically formats all code during build.
33
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
44

5+
// Compresses image plugin
6+
const Image = require("@11ty/eleventy-img");
7+
8+
// Node JS path functions
9+
const path = require('path');
10+
511
module.exports = function (eleventyConfig) {
612
// All folders called "assets" will be blindly copied
7-
// into the _site/assets output folder.
13+
// into the assets output folder.
814
eleventyConfig.addPassthroughCopy({ "src/**/assets/*": "assets/" });
915

1016
// Displays date in a human-readable way.
@@ -20,16 +26,36 @@ module.exports = function (eleventyConfig) {
2026
});
2127

2228
// Get all keys of a collection.
23-
eleventyConfig.addFilter('keys', obj => Object.keys( obj ) );
29+
eleventyConfig.addFilter('keys', obj => Object.keys(obj));
2430

2531
// Remove "all" and "post" from this list.
2632
eleventyConfig.addFilter("filterTagList", (tags) => {
27-
return (tags || []).filter(tag => !["all", "post"].includes(tag));
28-
});
29-
33+
return (tags || []).filter(tag => !["all", "post"].includes(tag));
34+
});
35+
3036

3137
eleventyConfig.addPlugin(syntaxHighlight);
3238

39+
// Image shortcode
40+
eleventyConfig.addShortcode("image", async function (src, alt, width = 90) {
41+
let metadata = await Image(`${path.dirname(this.page.inputPath)}/${src}`, {
42+
widths: [400, 800, 1200, "auto"],
43+
formats: ["jpeg"],
44+
urlPath: "/img/",
45+
outputDir: "public/img/"
46+
});
47+
48+
let imageAttributes = {
49+
alt,
50+
sizes: "(max-width: 50rem) 100vw, 50rem",
51+
style: `width: ${width}%;`,
52+
loading: "lazy",
53+
decoding: "async",
54+
};
55+
56+
return `<a href="${src}">${Image.generateHTML(metadata, imageAttributes)}</a>`;
57+
});
58+
3359
return {
3460
// Change the input and output directory
3561
dir: {

0 commit comments

Comments
 (0)