-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
const path = require('path') | ||
const eleventyImage = require('@11ty/eleventy-img') | ||
const path = require('path'); | ||
const eleventyImage = require('@11ty/eleventy-img'); | ||
|
||
module.exports = eleventyConfig => { | ||
function relativeToInputPath(inputPath, relativeFilePath) { | ||
let split = inputPath.split('/') | ||
split.pop() | ||
let split = inputPath.split('/'); | ||
split.pop(); | ||
|
||
return path.resolve(split.join(path.sep), relativeFilePath) | ||
return path.resolve(split.join(path.sep), relativeFilePath); | ||
} | ||
|
||
// 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 file = relativeToInputPath(this.page.inputPath, src) | ||
let formats = ['avif', 'webp', 'auto']; | ||
let file = relativeToInputPath(this.page.inputPath, src); | ||
let metadata = await eleventyImage(file, { | ||
widths: widths || ['auto'], | ||
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) | ||
}) | ||
} | ||
}; | ||
return eleventyImage.generateHTML(metadata, imageAttributes); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ module.exports = { | |
email: 'michaeluloth@gmail.com', | ||
url: 'https://michaeluloth.com/about/', | ||
}, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<script webc:type="js"> | ||
const now = new Date() | ||
const now = new Date(); | ||
|
||
;`© ${now.getFullYear()} Michael Uloth.` | ||
`© ${now.getFullYear()} Michael Uloth.`; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
eleventyExcludeFromCollections: true, | ||
} | ||
}; |