Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace abandoned eleventy-plugin-sharp with eleventy-img #349

Merged
merged 7 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading