Skip to content

Commit 10f6a34

Browse files
committed
feat: add size support to picture shortcode
1 parent 260e657 commit 10f6a34

File tree

9 files changed

+478
-504
lines changed

9 files changed

+478
-504
lines changed

Diff for: package-lock.json

+412-459
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@
2424
"@11ty/eleventy": "^0.11.1",
2525
"@11ty/eleventy-img": "^0.3.0",
2626
"@11ty/eleventy-navigation": "^0.1.6",
27-
"@babel/cli": "^7.12.1",
28-
"@babel/core": "^7.12.3",
29-
"@babel/preset-env": "^7.12.1",
30-
"babel-loader": "^8.1.0",
27+
"@babel/cli": "^7.12.8",
28+
"@babel/core": "^7.12.9",
29+
"@babel/preset-env": "^7.12.7",
30+
"babel-loader": "^8.2.2",
3131
"cheerio": "^1.0.0-rc.3",
32-
"core-js": "^3.7.0",
32+
"core-js": "^3.8.0",
3333
"cross-env": "^7.0.2",
3434
"css-loader": "^5.0.1",
3535
"date-fns": "^2.16.1",
3636
"eleventy-plugin-error-overlay": "^0.1.2",
3737
"html-minifier": "^4.0.0",
3838
"js-yaml": "^3.14.0",
3939
"markdown-it": "^12.0.2",
40-
"markdown-it-anchor": "^6.0.0",
40+
"markdown-it-anchor": "^6.0.1",
4141
"markdown-it-attrs": "^3.0.3",
4242
"markdown-it-bracketed-spans": "^1.0.1",
43-
"mini-css-extract-plugin": "^1.3.0",
43+
"mini-css-extract-plugin": "^1.3.1",
4444
"node-sass": "^5.0.0",
4545
"npm-run-all": "^4.1.5",
4646
"optimize-css-assets-webpack-plugin": "^5.0.4",
4747
"outdent": "^0.7.1",
48-
"postcss": "^8.1.6",
49-
"postcss-loader": "^4.0.4",
48+
"postcss": "^8.1.10",
49+
"postcss-loader": "^4.1.0",
5050
"postcss-preset-env": "^6.7.0",
51-
"prettier": "^2.1.2",
51+
"prettier": "^2.2.1",
5252
"rimraf": "^3.0.2",
53-
"sass-loader": "^10.0.5",
54-
"source-map-explorer": "^2.5.0",
53+
"sass-loader": "^10.1.0",
54+
"source-map-explorer": "^2.5.1",
5555
"svg-sprite": "^1.5.0",
5656
"vinyl": "^2.2.1",
57-
"webpack": "^5.4.0",
57+
"webpack": "^5.9.0",
5858
"webpack-cli": "^4.2.0",
5959
"webpack-manifest-plugin": "^3.0.0-rc.0"
6060
}

Diff for: src/assets/styles/base/_utilities.scss

+25-12
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,55 @@
3030
clear: both;
3131
}
3232

33-
.fs-small {
34-
font-size: $font-size-small;
33+
.t-small {
34+
font-size: $font-size-small !important;
3535
}
3636

37-
.fs-large {
38-
font-size: $font-size-large;
37+
.t-large {
38+
font-size: $font-size-large !important;
3939
}
4040

41-
.fw-normal {
42-
font-weight: normal;
41+
.t-normal {
42+
font-weight: normal !important;
4343
}
4444

45-
.fw-bold {
46-
font-weight: 700;
45+
.t-bold {
46+
font-weight: 700 !important;
47+
}
48+
49+
.t-center {
50+
text-align: center !important;
51+
}
52+
53+
.d-block {
54+
display: block !important;
4755
}
4856

4957
.d-flex {
5058
display: flex !important;
5159
}
5260

61+
.mx-auto {
62+
margin-left: auto !important;
63+
margin-right: auto !important;
64+
}
65+
5366
.mb-0 {
5467
margin-bottom: 0 !important;
5568
}
5669

5770
.mr-1 {
58-
margin-right: 0.25rem;
71+
margin-right: 0.25rem !important;
5972
}
6073

6174
.mr-2 {
62-
margin-right: 0.5rem;
75+
margin-right: 0.5rem !important;
6376
}
6477

6578
.ml-1 {
66-
margin-left: 0.25rem;
79+
margin-left: 0.25rem !important;
6780
}
6881

6982
.ml-2 {
70-
margin-left: 0.5rem;
83+
margin-left: 0.5rem !important;
7184
}

Diff for: src/includes/project.njk

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ layout: default
1212
{# {% if tags %}<span class="project__tags">{% for tag in tags %}<a href="/projects/{{ tag }}" class="project__tag">{{ tag }}</a>{% endfor%}</span>
1313
{% endif %} #}
1414
<time class="project__date" datetime="{{ page.date | formatISO }}">{{ page.date | format('LLL yyyy') }}</time>
15-
{% if image %}<div class="project__image">{% image image, title, null, null, false %}</div>{% endif %}
15+
{% if image %}<div class="project__image">{% image image, title, null, null, false, "90vw, (min-width: 782px) 43rem" %}</div>{% endif %}
1616
</header>
1717

1818
<div class="project__content">

Diff for: src/notes/ideas.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2+
date: 2019-11-11
23
draft: true
34
---
45

56
Ideas:
6-
* Privatezilla
77
* move outside of dropbox
88
* windows terminal
99
* nvm

Diff for: src/pages/home.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Clement Moron
66

77
<div class="container page home">
88

9-
# [Hello I’m Clement]{.page__title-pre .fw-bold} a frontend architect.{.page__title}
9+
# [Hello I’m Clement]{.page__title-pre .t-bold} a frontend architect.{.page__title}
1010

1111
I am also a [writer](notes/) and [definitely not]{.select-hide .select-hide--2} professional climber.
1212

Diff for: src/projects/2012-01-01_uikit.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The term _"living"_ means its an **ever-going process**.
2020

2121
In the course of **3+** years I iterated over this style guide and delivered not less then three versions.
2222

23-
### Version 1.0 [(2014)]{.fs-small .fw-normal}
23+
### Version 1.0 [(2014)]{.t-small .t-normal}
2424

2525
The first iteration was heavily inspired by [Bootstrap](https://getbootstrap.com/docs/3.3/components/) since it was the only style guide out there at the time.
2626

@@ -30,7 +30,7 @@ Components usage was similar to [ExtJs](https://docs.sencha.com/extjs/3.4.0/) li
3030

3131
{% image "uikit-v1-js.jpg", "Two column website showing the inputs section", "The Ext JS approach to components" %}
3232

33-
### Version 2.0 [(2015)]{.fs-small .fw-normal}
33+
### Version 2.0 [(2015)]{.t-small .t-normal}
3434

3535
With version 2.0 we split the library into Javascript and CSS components to make navigation easier.
3636

@@ -40,7 +40,7 @@ Additionally, every components would have it's own documentation page for easier
4040

4141
{% image "uikit-v2-js.jpg", "Full screen website with sidebar showing buttons section" , "A single unified page per component" %}
4242

43-
### Version 3.0 [(2016)]{.fs-small .fw-normal}
43+
### Version 3.0 [(2016)]{.t-small .t-normal}
4444

4545
The focus here was on clarity and quality. New documentations guides and examples were added.
4646

Diff for: src/projects/2018-01-01_docdash.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: open-source
88

99
Before the Typescript era, users had to resort to online documentation for guidance. {.lead}
1010

11-
In those dark age, it was common to **squint** at [tiny]{.fs-small} fonts and confusing UIs to find out what your function was supposed to return.
11+
In those dark age, it was common to **squint** at [tiny]{.t-small} fonts and confusing UIs to find out what your function was supposed to return.
1212

1313
{% image "docdash-angular.png", "Angular documentation website", "That documentation gave me nightmares" %}
1414

Diff for: utils/shortcodes.js

+21-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Image = require('@11ty/eleventy-img');
55
const markdown = require('./markdown');
66

77
const iconDefaultSize = 24;
8-
const defaultSizes = '90vw, (min-width: 1280px) 1152px';
8+
const defaultSizes = '90vw, (min-width: 782px) 41rem';
99
const defaultImagesSizes = [1920, 1280, 640, 320];
1010

1111
const isFullUrl = (url) => {
@@ -50,14 +50,21 @@ module.exports = {
5050

5151
// Allow embedding responsive images
5252
// {% image "image.jpeg", "Image alt", "Image title", "my-class" %}
53-
image: async (
54-
src,
55-
alt,
56-
title,
57-
className,
58-
lazy = true,
59-
sizes = defaultSizes
60-
) => {
53+
// {% image [100,100], "image.jpeg", "Image alt", "Image title", "my-class" %}
54+
image: async (...args) => {
55+
let fallbackWidth, fallbackHeight;
56+
57+
if (Array.isArray(args[0])) {
58+
[fallbackWidth, fallbackHeight] = args.shift();
59+
}
60+
61+
const src = args[0];
62+
const alt = args[1];
63+
const title = args[2];
64+
const className = args[3];
65+
const lazy = args[4] ?? true;
66+
const sizes = args[5] ?? defaultSizes;
67+
6168
const extension = path.extname(src).slice(1).toLowerCase();
6269
const fullSrc = isFullUrl(src) ? src : `./src/assets/images/${src}`;
6370

@@ -78,20 +85,21 @@ module.exports = {
7885

7986
const fallback = stats[extension].reverse()[0];
8087
const picture = outdent({ newline: '' })`
81-
<picture class="${!title && className || ''}">
88+
<picture class="${(!title && className) || ''}">
8289
${Object.values(stats)
8390
.map(
8491
(image) =>
8592
`<source type="image/${image[0].format}" srcset="${image
8693
.map((entry) => `${entry.url} ${entry.width}w`)
8794
.join(', ')}" sizes="${sizes}">`
88-
).join('')}
95+
)
96+
.join('')}
8997
<img
9098
class="img-fluid ${className || ''}"
9199
loading="${lazy ? 'lazy' : 'eager'}"
92100
src="${fallback.url}"
93-
width="${fallback.width}"
94-
height="${fallback.height}" alt="${alt}">
101+
width="${fallbackWidth ?? fallback.width}"
102+
height="${fallbackHeight ?? fallback.height}" alt="${alt}">
95103
</picture>`;
96104
return title
97105
? outdent({ newline: '' })`

0 commit comments

Comments
 (0)