Skip to content

Commit 62293b1

Browse files
committed
Shoot for four hundos Lighthouse score
1 parent 11f303b commit 62293b1

File tree

7 files changed

+79
-17
lines changed

7 files changed

+79
-17
lines changed

.eleventy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const htmlmin = require('html-minifier');
44
const sassWatch = require('./_includes/sass-watch');
55
const filter = require('./_includes/filter');
66
const scAvatar = require('./_includes/shortcodes/avatar');
7+
const scResponsiveImage = require('./_includes/shortcodes/responsive-image');
78
const scSocialSvg = require('./_includes/shortcodes/social-svg');
89
const scMeetupDetails = require('./_includes/shortcodes/meetup-details');
910
const scVideoPlayer = require('./_includes/shortcodes/video-player');
@@ -70,6 +71,9 @@ module.exports = (eleventyConfig) => {
7071
// SHORTCODE: Resize and cache images.
7172
eleventyConfig.addLiquidShortcode('avatar', scAvatar);
7273

74+
// SHORTCODE: Generate responsive image.
75+
eleventyConfig.addLiquidShortcode('responsiveImage', scResponsiveImage);
76+
7377
// SHORTCODE: Add social icon SVG block.
7478
eleventyConfig.addLiquidShortcode('socialSvg', scSocialSvg);
7579

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const Image = require('@11ty/eleventy-img');
2+
3+
module.exports = async (src, alt, outputFormat = 'jpeg') => {
4+
if (alt === undefined) {
5+
throw new Error(`Responsive Image: missing ALT attribute from: ${src}`);
6+
}
7+
8+
try {
9+
const stats = await Image(src, {
10+
formats: [outputFormat],
11+
urlPath: '/assets/img/',
12+
outputDir: '_site/assets/img/',
13+
widths: [400, 800, null],
14+
});
15+
16+
const lowestSrc = stats[outputFormat][0];
17+
const sizes = '(max-width: 400px) 400px, (max-width: 800px) 800px, 100vw';
18+
const sourceBlock = Object.values(stats).map((imageFormat) => `<source type="image/${imageFormat[0].format}" srcset="${imageFormat.map((entry) => `${entry.url} ${entry.width}w`).join(', ')}" sizes="${sizes}">`).join('\n');
19+
20+
return `<picture class="image">
21+
${sourceBlock}
22+
<img src="${lowestSrc.url}" width="${lowestSrc.width}" height="${lowestSrc.height}" alt="${alt}" loading="lazy">`;
23+
} catch (err) {
24+
// eslint-disable-next-line no-console
25+
console.error('Responsive Image: eleventy-img error:', err);
26+
27+
// load empty img src (as placeholder)
28+
return `<img src="" alt="${alt}" loading="lazy">`;
29+
}
30+
};

_layouts/base.liquid

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
<g id="logo-slack"><path d='M126.12,315.1A47.06,47.06,0,1,1,79.06,268h47.06Z'/><path d='M149.84,315.1a47.06,47.06,0,0,1,94.12,0V432.94a47.06,47.06,0,1,1-94.12,0Z'/><path d='M196.9,126.12A47.06,47.06,0,1,1,244,79.06v47.06Z'/><path d='M196.9,149.84a47.06,47.06,0,0,1,0,94.12H79.06a47.06,47.06,0,0,1,0-94.12Z'/><path d='M385.88,196.9A47.06,47.06,0,1,1,432.94,244H385.88Z'/><path d='M362.16,196.9a47.06,47.06,0,0,1-94.12,0V79.06a47.06,47.06,0,1,1,94.12,0Z'/><path d='M315.1,385.88A47.06,47.06,0,1,1,268,432.94V385.88Z'/><path d='M315.1,362.16a47.06,47.06,0,0,1,0-94.12H432.94a47.06,47.06,0,1,1,0,94.12Z'/></g>
3232
<g id="logo-twitter"><path d='M496,109.5a201.8,201.8,0,0,1-56.55,15.3,97.51,97.51,0,0,0,43.33-53.6,197.74,197.74,0,0,1-62.56,23.5A99.14,99.14,0,0,0,348.31,64c-54.42,0-98.46,43.4-98.46,96.9a93.21,93.21,0,0,0,2.54,22.1,280.7,280.7,0,0,1-203-101.3A95.69,95.69,0,0,0,36,130.4C36,164,53.53,193.7,80,211.1A97.5,97.5,0,0,1,35.22,199v1.2c0,47,34,86.1,79,95a100.76,100.76,0,0,1-25.94,3.4,94.38,94.38,0,0,1-18.51-1.8c12.51,38.5,48.92,66.5,92.05,67.3A199.59,199.59,0,0,1,39.5,405.6,203,203,0,0,1,16,404.2,278.68,278.68,0,0,0,166.74,448c181.36,0,280.44-147.7,280.44-275.8,0-4.2-.11-8.4-.31-12.5A198.48,198.48,0,0,0,496,109.5Z'/></g>
3333
</svg>
34-
<header class="page-header hero is-primary">
35-
<div class="hero-body is-paddingless">
34+
35+
<header class="page-header hero">
36+
<div class="hero-body is-primary is-paddingless">
3637
<div class="container">
3738
<div class="navbar" role="navigation" aria-label="main navigation">
3839
<div class="navbar-brand">
@@ -56,15 +57,11 @@
5657
</div>
5758
</div>
5859
</div>
59-
</header>
6060

61-
{%- if page.url == '/' -%}
62-
<section class="hero">
63-
<figure class="image">
64-
<img src="{{ '/assets/img/carlos-alfonso-AlBgcDfDG_s-unsplash_3by1-prog1.jpg' | url }}" alt="Austin skyline" title="Photo by Carlos Alfonso on Unsplash" loading="lazy">
65-
</figure>
66-
</section>
67-
{%- endif -%}
61+
{%- if page.url == '/' -%}
62+
{% responsiveImage "./assets/img/carlos-alfonso-AlBgcDfDG_s-unsplash_min.jpg", "Austin Skyline by Carlos Alfonso on Unsplash" %}
63+
{%- endif -%}
64+
</header>
6865

6966
<main class="page-main section has-background-white">
7067
<div class="container">

_sass/_main.scss

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@charset "utf-8";
22

33
// tetradic harmony via https://color.joelb.dev/hex/ED1878
4-
$tetradic0: hsl(333, 85%, 50%);
5-
$tetradic1: hsl(213, 85%, 50%);
4+
$tetradic0: hsl(333, 85%, 45%); // darkened 5% for a11y contrast
5+
$tetradic1: hsl(213, 85%, 45%); // darkened 5% for a11y contrast
66
$tetradic2: hsl(153, 85%, 40%); // lightness reduced by 10%
77
$tetradic3: hsl(33, 85%, 50%);
88

@@ -14,6 +14,7 @@ $info: $tetradic1;
1414
// @import "../node_modules/bulma/sass/utilities/_all.sass";
1515
@import "../node_modules/bulma/sass/utilities/initial-variables.sass";
1616

17+
$link: darken($blue, 3%); // darkened 3% for a11y contrast
1718
$scheme-main: $white-ter;
1819
$footer-background-color: $white-ter;
1920

@@ -78,19 +79,31 @@ $footer-background-color: $white-ter;
7879
* BULMA CUSTOMIZATIONS
7980
*/
8081

81-
.hero.is-primary {
82+
.hero-body.is-primary {
83+
background-color: $primary;
84+
8285
.navbar-item,
8386
.navbar-link {
8487
// reduce opacity for a11y color contrast
8588
color: hsla(0, 100%, 100%, 0.8);
89+
90+
&:hover,
91+
&:focus {
92+
background-color: darken($primary, 5%);
93+
}
8694
}
8795
}
8896

97+
.content li + li {
98+
margin-top: 0.5em;
99+
}
100+
89101
.icon {
90102
vertical-align: bottom;
91103

92104
.card & {
93105
margin-top: 2px;
106+
width: 2em;
94107
}
95108

96109
@media screen and (min-width: $desktop) {
@@ -100,6 +113,15 @@ $footer-background-color: $white-ter;
100113
}
101114
}
102115

116+
.icon-item {
117+
fill: currentColor;
118+
width: 84%;
119+
120+
.message-body & {
121+
width: 71%;
122+
}
123+
}
124+
103125
.page-main {
104126
a {
105127
text-decoration: underline;

_sass/_tooltips.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* TOOLTIP
33
*/
44

5-
.tooltip[title] {
5+
.tooltip[aria-label] {
66
position: relative;
77

88
.pic & {
@@ -27,7 +27,7 @@
2727
background-color: hsla(0, 0%, 20%, 0.95);
2828
border-radius: 3px;
2929
color: #fff;
30-
content: attr(title);
30+
content: attr(aria-label);
3131
font-size: 14px;
3232
line-height: 1.2;
3333
margin-bottom: 5px;
59.4 KB
Loading

index.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ <h1 class="is-sr-only">{{ title }}</h1>
1414
{%- meetupDetails meet.date, meet.data.venue, meet.data.after, 'Upcoming meetup details', meet.data.title, meet.url -%}
1515

1616
<meta id="meet-date" time="{{ meet.date }}">
17+
<script>
18+
(function () {
19+
const meetDate = document.getElementById('meet-date').getAttribute('time');
20+
if (new Date(meetDate) < new Date()) {
21+
// We may want to post an alternate message, but for now just delete the upcoming meetup.
22+
document.querySelector('.meetup-details').remove();
23+
}
24+
}());
25+
</script>
1726
</section>
1827

1928
<section class="section">
@@ -22,12 +31,12 @@ <h1 class="is-sr-only">{{ title }}</h1>
2231
</section>
2332

2433
<section class="section">
25-
<h3>Past speakers and talks</h3>
34+
<h2 class="is-size-4">Past speakers and talks</h2>
2635
{%- for meetup in collections.meetups reversed -%}
2736
{%- for speaker in meetup.data.speakers -%}
2837
{%- if speaker.name and speaker.avatar -%}
2938
<figure class="pic">
30-
<a class="tooltip" href="{{ meetup.url | url }}" title="{{ speaker.name }}: &quot;{{ meetup.data.title }}&quot;">
39+
<a class="tooltip" href="{{ meetup.url | url }}" aria-label="{{ speaker.name }}: &quot;{{ meetup.data.title }}&quot;">
3140
{%- avatar speaker.avatar, speaker.name, 'is-rounded' -%}
3241
</a>
3342
</figure>

0 commit comments

Comments
 (0)