Skip to content

Commit

Permalink
fix: replace abandoned eleventy-plugin-sharp with eleventy-img (#349)
Browse files Browse the repository at this point in the history
* fix: replace abandoned eleventy-plugin-sharp with eleventy-img

Resolves #345.

* chore: bump to Node 20

* fix: remove Sharp references

* fix: bump dependencies

* fix: resolve lock file issues

* fix: remove sharp
  • Loading branch information
greatislander authored Apr 24, 2024
1 parent 67bbef3 commit bfeb4c1
Show file tree
Hide file tree
Showing 7 changed files with 2,620 additions and 2,772 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
20
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS builder
FROM node:20-alpine AS builder

WORKDIR /app

Expand Down
23 changes: 17 additions & 6 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const pkg = require("./package.json");
const fluidPlugin = require("eleventy-plugin-fluid");
const navigationPlugin = require("@11ty/eleventy-navigation");
const rssPlugin = require("@11ty/eleventy-plugin-rss");
const sharpPlugin = require("eleventy-plugin-sharp");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const eleventyImg = require("@11ty/eleventy-img");

// Import filters
const dateFilter = require("./src/filters/date-filter.js");
Expand Down Expand Up @@ -63,6 +63,22 @@ module.exports = function (config) {
});
return text;
});
config.addShortcode("thumbnail", async function (src, alt) {
let metadata = await eleventyImg(src, {
widths: [500],
formats: ["jpeg"],
urlPath: "/projects/images/",
outputDir: "./_site/projects/images/"
});

let imageAttributes = {
alt,
loading: "lazy",
decoding: "async"
};

return eleventyImg.generateHTML(metadata, imageAttributes);
});

// Transforms
config.addTransform("parse", parseTransform);
Expand All @@ -74,11 +90,6 @@ module.exports = function (config) {
config.addPassthroughCopy({"src/collections/news/images": "news/images"});
config.addPassthroughCopy({"src/collections/projects/images": "projects/images"});

// Plugins
config.addPlugin(sharpPlugin({
urlPath: "/projects/images",
outputDir: "_site/projects/images"
}));
config.addPlugin(fluidPlugin, {
css: {
browserslist: pkg.browserslist.join(", ")
Expand Down
Loading

0 comments on commit bfeb4c1

Please sign in to comment.