Skip to content

Commit 9947067

Browse files
author
LinuxJava7
committed
remove eleventy-img and move pictures into new directory
1 parent 9607829 commit 9947067

File tree

8 files changed

+33
-717
lines changed

8 files changed

+33
-717
lines changed

_config/filters.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
import { DateTime } from "luxon";
2-
import fs from 'fs';
3-
import path from 'path';
4-
import { fileURLToPath } from 'url';
2+
import fs from "fs";
3+
import path from "path";
4+
import { fileURLToPath } from "url";
55

66
const __filename = fileURLToPath(import.meta.url);
77
const __dirname = path.dirname(__filename);
88

9-
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
10-
export default function(eleventyConfig) {
9+
export default function (eleventyConfig) {
1110
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
1211
// Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
13-
return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy");
12+
return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(
13+
format || "dd LLLL yyyy",
14+
);
1415
});
1516

1617
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
1718
// dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
18-
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat('yyyy-LL-dd');
19+
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd");
1920
});
2021

2122
// Get the first `n` elements of a collection.
2223
eleventyConfig.addFilter("head", (array, n) => {
23-
if(!Array.isArray(array) || array.length === 0) {
24+
if (!Array.isArray(array) || array.length === 0) {
2425
return [];
2526
}
26-
if( n < 0 ) {
27+
if (n < 0) {
2728
return array.slice(n);
2829
}
2930

@@ -36,32 +37,38 @@ export default function(eleventyConfig) {
3637
});
3738

3839
// Return the keys used in an object
39-
eleventyConfig.addFilter("getKeys", target => {
40+
eleventyConfig.addFilter("getKeys", (target) => {
4041
return Object.keys(target);
4142
});
4243

4344
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
44-
return (tags || []).filter(tag => ["all", "posts"].indexOf(tag) === -1);
45+
return (tags || []).filter((tag) => ["all", "posts"].indexOf(tag) === -1);
4546
});
4647

47-
eleventyConfig.addFilter("sortAlphabetically", strings =>
48-
(strings || []).sort((b, a) => b.localeCompare(a))
48+
eleventyConfig.addFilter("sortAlphabetically", (strings) =>
49+
(strings || []).sort((b, a) => b.localeCompare(a)),
4950
);
5051

51-
eleventyConfig.addFilter("inlineSvg", function(iconName) {
52-
if (!iconName) return '';
53-
54-
const iconPath = path.join(__dirname, '..', '_includes', 'icons', `${iconName}.svg`);
55-
52+
eleventyConfig.addFilter("inlineSvg", function (iconName) {
53+
if (!iconName) return "";
54+
55+
const iconPath = path.join(
56+
__dirname,
57+
"..",
58+
"_includes",
59+
"icons",
60+
`${iconName}.svg`,
61+
);
62+
5663
try {
5764
if (fs.existsSync(iconPath)) {
58-
const svg = fs.readFileSync(iconPath, 'utf8');
65+
const svg = fs.readFileSync(iconPath, "utf8");
5966
return svg;
6067
}
61-
return '';
68+
return "";
6269
} catch (err) {
6370
console.warn(`Could not load SVG icon: ${iconName}`, err);
64-
return '';
71+
return "";
6572
}
6673
});
6774
}

eleventy.config.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
77
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
88
import pluginNavigation from "@11ty/eleventy-navigation";
9-
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
109

1110
import pluginFilters from "./_config/filters.js";
1211

@@ -32,8 +31,6 @@ export default async function (eleventyConfig) {
3231

3332
// Watch CSS files
3433
eleventyConfig.addWatchTarget("css/**/*.css");
35-
// Watch images for the image pipeline.
36-
eleventyConfig.addWatchTarget("content/**/*.{svg,webp,png,jpg,jpeg,gif}");
3734

3835
// Per-page bundles, see https://github.com/11ty/eleventy-plugin-bundle
3936
// Bundle <style> content and adds a {% css %} paired shortcode
@@ -85,32 +82,11 @@ export default async function (eleventyConfig) {
8582
},
8683
});
8784

88-
// Image optimization: https://www.11ty.dev/docs/plugins/image/#eleventy-transform
89-
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
90-
// Output formats for each image.
91-
formats: ["avif", "webp", "auto"],
92-
93-
// widths: ["auto"],
94-
95-
failOnError: false,
96-
htmlOptions: {
97-
imgAttributes: {
98-
// e.g. <img loading decoding> assigned on the HTML tag will override these values.
99-
loading: "lazy",
100-
decoding: "async",
101-
},
102-
},
103-
104-
sharpOptions: {
105-
animated: true,
106-
},
107-
});
108-
10985
// Filters
11086
eleventyConfig.addPlugin(pluginFilters);
11187

11288
eleventyConfig.addPlugin(IdAttributePlugin, {
113-
// by default we use Eleventys built-in `slugify` filter:
89+
// by default we use Eleventy's built-in `slugify` filter:
11490
// slugify: eleventyConfig.getFilter("slugify"),
11591
// selector: "h1,h2,h3,h4,h5,h6", // default
11692
});

0 commit comments

Comments
 (0)