Skip to content

Commit

Permalink
Merge pull request #63 from Kuadrant/kuadrant-roadmap
Browse files Browse the repository at this point in the history
Add post on kuadrant process & roadmap
  • Loading branch information
openshift-merge-bot[bot] authored Aug 21, 2024
2 parents 1519528 + dd57563 commit d5f95c3
Show file tree
Hide file tree
Showing 9 changed files with 1,301 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const string = require('string')
const slugify = s => string(s).slugify().toString()
const eleventyAsciidoc = require("eleventy-plugin-asciidoc");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const pluginImages = require("./eleventy.config.images.js");


module.exports = function(eleventyConfig) {
Expand All @@ -21,6 +22,9 @@ module.exports = function(eleventyConfig) {
linkify: true
};

// Watch content images for the image pipeline.
eleventyConfig.addWatchTarget("content/**/*.{svg,webp,png,jpeg}");

eleventyConfig.setLibrary(
'md',
markdownIt(markdownItOptions).use(markdownItAnchor, {
Expand All @@ -29,6 +33,7 @@ module.exports = function(eleventyConfig) {
})
);
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(pluginImages);

eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
// Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
resources
_site
/img
51 changes: 51 additions & 0 deletions eleventy.config.images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const path = require("path");
const eleventyImage = require("@11ty/eleventy-img");

function relativeToInputPath(inputPath, relativeFilePath) {
let split = inputPath.split("/");
split.pop();

return path.resolve(split.join(path.sep), relativeFilePath);

}

function isFullUrl(url) {
try {
new URL(url);
return true;
} catch(e) {
return false;
}
}

module.exports = function(eleventyConfig) {
// Eleventy Image shortcode
// https://www.11ty.dev/docs/plugins/image/
eleventyConfig.addAsyncShortcode("image", async function imageShortcode(src, alt, widths, sizes) {
// Full list of formats here: https://www.11ty.dev/docs/plugins/image/#output-formats
// Warning: Avif can be resource-intensive so take care!
let formats = ["avif", "webp", "auto"];
let input;
if(isFullUrl(src)) {
input = src;
} else {
input = relativeToInputPath(this.page.inputPath, src);
}

let metadata = await eleventyImage(input, {
widths: widths || ["900,600,300"],
formats,
outputDir: path.join(eleventyConfig.dir.output, "img"), // Advanced usage note: `eleventyConfig.dir` works here because we’re using addPlugin.
});

// TODO loading=eager and fetchpriority=high
let imageAttributes = {
alt,
sizes,
loading: "lazy",
decoding: "async",
};

return eleventyImage.generateHTML(metadata, imageAttributes);
});
};
Loading

0 comments on commit d5f95c3

Please sign in to comment.