Compare commits
147 Commits
freecodeca
...
main
Author | SHA1 | Date |
---|---|---|
Robert McGovern | 29fdeb0163 | |
Robert McGovern | 7388b5e700 | |
Robert McGovern | 85517d94f6 | |
Robert McGovern | dbe6e0ee65 | |
Robert McGovern | b4d6c6bb3e | |
Robert McGovern | 5703554898 | |
Robert McGovern | 19881c7ffd | |
Robert McGovern | cffbfd3121 | |
Robert McGovern | 4fbe3dd159 | |
Robert McGovern | 557f2f157a | |
Robert McGovern | ba5ed4756d | |
Robert McGovern | a4a402ea8e | |
Robert McGovern | e69bf49e05 | |
Robert McGovern | 2a9d10af21 | |
Robert McGovern | bd79b9c569 | |
Robert McGovern | e3aaceb931 | |
Robert McGovern | d6fac9cd61 | |
Robert McGovern | 3dd7d307b2 | |
Robert McGovern | 0140cb3324 | |
Robert McGovern | 063dbdd28e | |
Robert McGovern | 70ad2cec50 | |
Robert McGovern | e8915df1cc | |
Robert McGovern | d395f8eeda | |
Robert McGovern | 621867856a | |
Robert McGovern | cf700fd456 | |
Robert McGovern | 9637f47d8f | |
Robert McGovern | 8d98f542a6 | |
Robert McGovern | f5f2b205e4 | |
Robert McGovern | 81aacd98f0 | |
Robert McGovern | 297bed46bb | |
Robert McGovern | 3f09aa4445 | |
Robert McGovern | b1b5630200 | |
Robert McGovern | 3eaa430a70 | |
Robert McGovern | 011b455043 | |
Robert McGovern | 5249256339 | |
Robert McGovern | c83cb021c7 | |
Robert McGovern | b170525dd2 | |
Robert McGovern | 9f3755c6d8 | |
Robert McGovern | 5bdd8032f2 | |
Robert McGovern | 77d12b2e24 | |
Robert McGovern | 43d25f0bcb | |
Robert McGovern | 2abe6df04c | |
Robert McGovern | 220d4fc991 | |
Robert McGovern | 33e77d0a8c | |
Robert McGovern | 5e8d5f4abf | |
Robert McGovern | 8c0fe3ab26 | |
Robert McGovern | eb4b2dbefb | |
Robert McGovern | 594cc89fa3 | |
Robert McGovern | 848f2dfd65 | |
Robert McGovern | a6c3745e11 | |
Robert McGovern | 611c355399 | |
Robert McGovern | 67718cea21 | |
Robert McGovern | 2a3cdd7544 | |
Robert McGovern | 4b515a74bc | |
Robert McGovern | 1c54ac076b | |
Robert McGovern | 58033f2d68 | |
Robert McGovern | db2c8e2433 | |
Robert McGovern | 7c09f64baa | |
Robert McGovern | 076a16d32e | |
Robert McGovern | 8dc58d6e59 | |
Robert McGovern | fa08527d1a | |
Robert McGovern | 461c76ab61 | |
Robert McGovern | 97e9160ae5 | |
Robert McGovern | c20c26ea42 | |
Robert McGovern | 700f54052c | |
Robert McGovern | 4995e1c9e4 | |
Robert McGovern | 405cb41098 | |
Robert McGovern | 060056e793 | |
Robert McGovern | aa9a4c5903 | |
Robert McGovern | 97711fe4ae | |
Robert McGovern | 7da1a73f83 | |
Robert McGovern | eaf3b5ffd3 | |
Robert McGovern | cf5c127a36 | |
Robert McGovern | 8a2ee0166e | |
Robert McGovern | 602cd4c992 | |
Robert McGovern | fec83b8319 | |
Robert McGovern | 95e6bc6778 | |
Robert McGovern | e88efb2c93 | |
Robert McGovern | c1f5a140e4 | |
Robert McGovern | 18507c0697 | |
Robert McGovern | 7942635664 | |
Robert McGovern | 616f84c7d1 | |
Robert McGovern | 43f4096b2d | |
Robert McGovern | 7b0b8f2dc6 | |
Robert McGovern | 6d84eb2185 | |
Robert McGovern | b382ab8b8d | |
Robert McGovern | c10ff7bb7a | |
Robert McGovern | 103ac58257 | |
Robert McGovern | af20f14f95 | |
Robert McGovern | 9108768c6b | |
Robert McGovern | 16bb008cdd | |
Robert McGovern | 590a51488d | |
Robert McGovern | e2de50e1a3 | |
Robert McGovern | 3a6bf65eba | |
Robert McGovern | 41829dbb47 | |
Robert McGovern | 7358c8288f | |
Robert McGovern | 4f87fa5031 | |
Robert McGovern | 6797bf0b5e | |
Robert McGovern | e4ebe327b7 | |
Robert McGovern | 99b4792200 | |
Robert McGovern | f60b524f86 | |
Robert McGovern | 7684f4698c | |
Robert McGovern | 869b838a76 | |
Robert McGovern | 864a81faaf | |
Robert McGovern | a65a624dfc | |
Robert McGovern | 03afd40b57 | |
Robert McGovern | 86a559963e | |
Robert McGovern | 2cc18325ae | |
Robert McGovern | 8babca497a | |
Robert McGovern | 48254efc6c | |
Robert McGovern | 5639e33439 | |
Robert McGovern | da6a2fd540 | |
Robert McGovern | db9cd8d911 | |
Robert McGovern | a2bda7b1c0 | |
Robert McGovern | 894f0cfd85 | |
Robert McGovern | d9b756807b | |
Robert McGovern | 02123ff338 | |
Robert McGovern | 05e78e1615 | |
Robert McGovern | 0260d5f87a | |
Robert McGovern | 2c829c03d1 | |
Robert McGovern | f904bafbb0 | |
Robert McGovern | 75094cc939 | |
Robert McGovern | 390d8a5d12 | |
Robert McGovern | 2880bcb95b | |
Robert McGovern | a439bc3325 | |
Robert McGovern | 9e2d016048 | |
Robert McGovern | ee451daa6b | |
Robert McGovern | ded1d85b97 | |
Robert McGovern | 7a6c0a5b66 | |
Robert McGovern | ed604c1e64 | |
Robert McGovern | 5169534ba4 | |
Robert McGovern | a1bdd8374a | |
Robert McGovern | ec201ea5d3 | |
Robert McGovern | ea94fb7a42 | |
Robert McGovern | f2e9f52639 | |
Robert McGovern | a42a248f29 | |
Robert McGovern | 68dbbf3229 | |
Robert McGovern | 5b661d6ddd | |
Robert McGovern | c796607c4f | |
Robert McGovern | 01fad08c4d | |
Robert McGovern | f9ba9e8891 | |
Robert McGovern | 4be741a09b | |
Robert McGovern | 5f0e68b80b | |
Robert McGovern | 9e3dfc5d16 | |
Robert McGovern | 87a7a868dc | |
Robert McGovern | 1993993b97 | |
Robert McGovern | 6af38191a7 |
169
.eleventy.js
|
@ -1,6 +1,9 @@
|
|||
const { EleventyRenderPlugin } = require("@11ty/eleventy");
|
||||
const Image = require("@11ty/eleventy-img");
|
||||
const CleanCSS = require("clean-css");
|
||||
|
||||
module.exports = async function (eleventyConfig) {
|
||||
const { EleventyRenderPlugin } = await import("@11ty/eleventy");
|
||||
|
||||
module.exports = function (eleventyConfig) {
|
||||
eleventyConfig.addPassthroughCopy("./src/css");
|
||||
eleventyConfig.addPassthroughCopy("./src/fonts");
|
||||
eleventyConfig.addPassthroughCopy("./src/images");
|
||||
|
@ -13,6 +16,12 @@ module.exports = function (eleventyConfig) {
|
|||
eleventyConfig.addPassthroughCopy({
|
||||
"./projects/FrontendMentor": "FrontendMentor",
|
||||
});
|
||||
eleventyConfig.addPassthroughCopy({
|
||||
"./projects/random": "others",
|
||||
});
|
||||
eleventyConfig.addPassthroughCopy({
|
||||
"./projects/devchallenges": "devchallenges",
|
||||
});
|
||||
eleventyConfig.addPassthroughCopy({
|
||||
"./src/assets/faviconstuff": "/",
|
||||
});
|
||||
|
@ -21,9 +30,20 @@ module.exports = function (eleventyConfig) {
|
|||
// "./src/assets/images": "img",
|
||||
//});
|
||||
|
||||
// FILTERS
|
||||
eleventyConfig.addFilter("cssmin", function (code) {
|
||||
return new CleanCSS({}).minify(code).styles;
|
||||
});
|
||||
|
||||
// PLUGINS
|
||||
eleventyConfig.addPlugin(EleventyRenderPlugin);
|
||||
|
||||
// SHORTCODES
|
||||
// eleventyConfig.addShortcode("image", imageShortcode);
|
||||
eleventyConfig.addAsyncShortcode("imageGen", officialImageShortcode);
|
||||
eleventyConfig.addNunjucksShortcode("imageGenSync", imageShortcodeSync);
|
||||
// eleventyConfig.addShortcode("imageGenSync", imageShortcodeSync);
|
||||
|
||||
// WATCH Targets
|
||||
eleventyConfig.addWatchTarget("./src/css/");
|
||||
eleventyConfig.addWatchTarget("./src/js/");
|
||||
|
@ -45,3 +65,148 @@ module.exports = function (eleventyConfig) {
|
|||
},
|
||||
};
|
||||
};
|
||||
|
||||
const imageShortcode = async (
|
||||
src,
|
||||
alt,
|
||||
className = undefined,
|
||||
widths = [400, 800, 1280],
|
||||
formats = ["webp", "jpeg"],
|
||||
sizes = "100vw"
|
||||
) => {
|
||||
const imageMetadata = await Image(src, {
|
||||
widths: [...widths, null],
|
||||
formats: [...formats, null],
|
||||
outputDir: "_site/assets/images",
|
||||
urlPath: "/assets/images",
|
||||
});
|
||||
|
||||
const sourceHtmlString = Object.values(imageMetadata)
|
||||
// Map each format to the source HTML markup
|
||||
.map((images) => {
|
||||
// The first entry is representative of all the others
|
||||
// since they each have the same shape
|
||||
const { sourceType } = images[0];
|
||||
|
||||
// Use our util from earlier to make our lives easier
|
||||
const sourceAttributes = stringifyAttributes({
|
||||
type: sourceType,
|
||||
// srcset needs to be a comma-separated attribute
|
||||
srcset: images.map((image) => image.srcset).join(", "),
|
||||
sizes,
|
||||
});
|
||||
|
||||
// Return one <source> per format
|
||||
return `<source ${sourceAttributes}>`;
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
const getLargestImage = (format) => {
|
||||
const images = imageMetadata[format];
|
||||
return images[images.length - 1];
|
||||
};
|
||||
|
||||
const largestUnoptimizedImg = getLargestImage(formats[0]);
|
||||
const imgAttributes = stringifyAttributes({
|
||||
src: largestUnoptimizedImg.url,
|
||||
width: largestUnoptimizedImg.width,
|
||||
height: largestUnoptimizedImg.height,
|
||||
alt,
|
||||
loading: "lazy",
|
||||
decoding: "async",
|
||||
});
|
||||
const imgHtmlString = `<img ${imgAttributes}>`;
|
||||
|
||||
const pictureAttributes = stringifyAttributes({
|
||||
class: className,
|
||||
});
|
||||
const picture = `<picture ${pictureAttributes}>
|
||||
${sourceHtmlString}
|
||||
${imgHtmlString}
|
||||
</picture>`;
|
||||
|
||||
return outdent`${picture}`;
|
||||
};
|
||||
|
||||
async function officialImageShortcode(src, alt, sizes = "100vw") {
|
||||
if (alt === undefined) {
|
||||
// You bet we throw an error on missing alt (alt="" works okay)
|
||||
throw new Error(`Missing \`alt\` on responsiveimage from: ${src}`);
|
||||
}
|
||||
|
||||
if (src.startsWith("/screenshots")) {
|
||||
src = "./src/" + src;
|
||||
} else {
|
||||
src = "./projects/" + src;
|
||||
}
|
||||
|
||||
console.log("officalImage: " + src + " " + alt);
|
||||
|
||||
let metadata = await Image(src, {
|
||||
widths: [300, 600],
|
||||
formats: ["webp", "jpeg"],
|
||||
outputDir: "www/assets/images",
|
||||
urlPath: "/assets/images",
|
||||
});
|
||||
|
||||
console.log(metadata);
|
||||
|
||||
let lowsrc = metadata.jpeg[0];
|
||||
let highsrc = metadata.jpeg[metadata.jpeg.length - 1];
|
||||
|
||||
return `<picture>
|
||||
${Object.values(metadata)
|
||||
.map((imageFormat) => {
|
||||
return ` <source type="${
|
||||
imageFormat[0].sourceType
|
||||
}" srcset="${imageFormat
|
||||
.map((entry) => entry.srcset)
|
||||
.join(", ")}" sizes="${sizes}">`;
|
||||
})
|
||||
.join("\n")}
|
||||
<img
|
||||
src="${lowsrc.url}"
|
||||
width="${highsrc.width}"
|
||||
height="${highsrc.height}"
|
||||
alt="${alt}"
|
||||
class="card__img"
|
||||
loading="lazy"
|
||||
decoding="async">
|
||||
</picture>`;
|
||||
}
|
||||
|
||||
function imageShortcodeSync(
|
||||
src,
|
||||
alt,
|
||||
sizes = "100vw",
|
||||
widths = [300, 600],
|
||||
cls = "card__img"
|
||||
) {
|
||||
let options = {
|
||||
widths: widths,
|
||||
formats: ["webp", "jpeg"],
|
||||
outputDir: "www/assets/images",
|
||||
urlPath: "/assets/images",
|
||||
};
|
||||
|
||||
if (src.startsWith("/screenshots")) {
|
||||
src = "./src/" + src;
|
||||
} else {
|
||||
src = "./projects/" + src;
|
||||
}
|
||||
|
||||
// console.log("Sync: " + src + " " + alt);
|
||||
// generate images, while this is async we don’t wait
|
||||
Image(src, options);
|
||||
|
||||
let imageAttributes = {
|
||||
class: cls,
|
||||
alt,
|
||||
sizes,
|
||||
loading: "lazy",
|
||||
decoding: "async",
|
||||
};
|
||||
// get metadata even if the images are not fully generated yet
|
||||
let metadata = Image.statsSync(src, options);
|
||||
return Image.generateHTML(metadata, imageAttributes);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [17.x]
|
||||
node-version: [20.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -30,6 +30,8 @@ src/_includes/css
|
|||
# my chosen output directory.
|
||||
www
|
||||
|
||||
**/*/premdesigns
|
||||
|
||||
#### From FrontEnd Mentor gitignore. Just to avoid accidentally uploading design files
|
||||
#
|
||||
# Avoid accidental upload of the Sketch and Figma design files
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"extends": ["development"],
|
||||
"browserslist": ["defaults", "not IE 11"]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "edge",
|
||||
"version": "stable",
|
||||
"request": "launch",
|
||||
"name": "Launch Edge against localhost",
|
||||
"url": "http://localhost:8080",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "projects/FrontendMentor/junior/github-user-search-app"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
|
|
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 6.8 KiB |