Skip to content

Commit a3c4931

Browse files
authored
Merge pull request #501 from webstackdev/maintenance/refactor-html-img-to-astro-image-component
Maintenance/refactor html img to astro image component
2 parents 4a2949e + 1729d79 commit a3c4931

68 files changed

Lines changed: 950 additions & 1073 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
pull_request:
99
branches:
1010
- main
11-
schedule:
12-
# Run at 6 AM UTC every Monday
13-
- cron: '0 6 * * 1'
1411

1512
jobs:
1613
analyze:

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"gomodule",
4242
"GSAP",
4343
"hocho",
44+
"htmlcsstoimage",
4445
"Hudi",
4546
"interrobang",
4647
"izakaya",
@@ -121,6 +122,7 @@
121122
"Veeam",
122123
"vercel",
123124
"virt",
125+
"vite",
124126
"vmax",
125127
"vtbot",
126128
"WHATWG",

_TODO.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,27 @@ Allows any Mastodon instance to discover your Mastodon profile directly from you
410410
</body>
411411
```
412412

413+
## Refactor social neworks in Authors collection to Contact collection format
414+
415+
The contact data collection uses an array of social networks, with keys:
416+
417+
```
418+
{
419+
network: z.string(),
420+
name: z.string(),
421+
url: z.string().url(),
422+
order: z.number(),
423+
}
424+
```
425+
426+
The authors collection is using named entries under a "social" property, like "twitter", "github", etc. This task is to refactor that to use an array like contact data collection. We also need to add a color for the social network icon, or some other approach to setting the color of it while enabling theming.
427+
428+
We should also make sure the avatar key in the authors collection is being output as a responsive image tag.
429+
430+
## Add Google Maps screenshot (or maps embed) to Contact Page
431+
432+
src/assets/images/map.webp
433+
413434
## Display a system font until font files load (Lighthouse improvements)
414435

415436
Display a system font until font files load to improve FCP (First Contentful Paint) with `font-display: swap`. Need to make sure that web font doesn't render larger or smaller than the system font fallback to avoid CLS (Cumulative Layout Shift) issues.
-24.3 KB
Binary file not shown.
File renamed without changes.
-13.4 KB
Binary file not shown.

src/components/Carousel/client/__fixtures__/collection.fixture.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,55 @@
1+
import type { ImageMetadata } from 'astro'
2+
3+
const createCover = (src: string, format: ImageMetadata['format'] = 'jpeg'): ImageMetadata => ({
4+
src,
5+
width: 1200,
6+
height: 675,
7+
format,
8+
})
9+
110
const sampleCollection = [
211
{
312
id: 'article-one',
413
data: {
514
title: 'Article One',
615
description: 'First test entry',
7-
publishDate: '2024-01-01',
16+
publishDate: new Date('2024-01-01'),
817
featured: true,
9-
icon: '/icons/one.svg',
18+
cover: createCover('/_astro/article-one.jpg'),
19+
coverAlt: 'Cover image for Article One',
1020
},
1121
},
1222
{
1323
id: 'article-two',
1424
data: {
1525
title: 'Article Two',
1626
description: 'Second test entry',
17-
publishDate: '2024-02-01',
27+
publishDate: new Date('2024-02-01'),
1828
featured: true,
29+
cover: createCover('/_astro/article-two.jpg'),
30+
coverAlt: 'Cover image for Article Two',
1931
},
2032
},
2133
{
2234
id: 'article-three',
2335
data: {
2436
title: 'Article Three',
2537
description: 'Third test entry',
26-
publishDate: '2024-03-01',
38+
publishDate: new Date('2024-03-01'),
2739
featured: false,
40+
cover: createCover('/_astro/article-three.jpg'),
41+
coverAlt: 'Cover image for Article Three',
2842
},
2943
},
3044
{
3145
id: 'article-four',
3246
data: {
3347
title: 'Article Four',
3448
description: 'Fourth test entry',
35-
publishDate: '2024-04-01',
49+
publishDate: new Date('2024-04-01'),
3650
featured: false,
51+
cover: createCover('/_astro/article-four.jpg'),
52+
coverAlt: 'Cover image for Article Four',
3753
},
3854
},
3955
]

src/components/Carousel/client/__tests__/index.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ describe('Carousel component (server output)', () => {
142142
const cardWithIcon = root.querySelector('[data-carousel-slide] img')
143143

144144
expect(cardWithIcon).toBeTruthy()
145-
expect(cardWithIcon?.getAttribute('src')).toBe('/icons/one.svg')
145+
expect(cardWithIcon?.getAttribute('src')).toMatch(/^\/_image\?href=/)
146+
expect(cardWithIcon?.getAttribute('alt')).toBe('Cover image for Article One')
146147
})
147148
})
148149

src/components/Carousel/index.astro

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
2-
// Generic Carousel component for displaying content - both featured and suggested
2+
/**
3+
* Generic Carousel component for displaying content - both featured and suggested
4+
*/
5+
import { Picture } from 'astro:assets'
36
import { getCollection } from 'astro:content'
7+
48
import {
59
type CollectionSlug,
610
type CarouselVariant,
@@ -52,11 +56,19 @@ const items = prepareItems(allItems, variant, currentSlug, limit)
5256
href={`/${type}/${item.id}`}
5357
class="block h-full bg-bg rounded-xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden border border-border hover:border-primary transform hover:-translate-y-2"
5458
>
55-
{'icon' in item.data && item.data.icon && (
56-
<div class="p-6 pb-4">
57-
<div class="w-12 h-12 bg-bg-offset rounded-lg flex items-center justify-center group-hover:bg-primary group-hover:bg-opacity-20 transition-colors">
58-
<img src={item.data.icon} alt="" loading="lazy" class="w-6 h-6" />
59-
</div>
59+
{item.data.cover && (
60+
<div class="relative aspect-video overflow-hidden">
61+
<Picture
62+
src={item.data.cover}
63+
alt={item.data.coverAlt}
64+
widths={[320, 640, 960, 1280]}
65+
sizes="(min-width: 1024px) 33vw, (min-width: 768px) 50vw, 100vw"
66+
formats={['avif', 'webp', 'jpeg']}
67+
layout="constrained"
68+
fit="cover"
69+
position="center"
70+
class="absolute inset-0 h-full w-full"
71+
/>
6072
</div>
6173
)}
6274
<div class="p-6 pt-2">

0 commit comments

Comments
 (0)