Skip to content
This repository was archived by the owner on Feb 9, 2025. It is now read-only.

Commit 10a4c1b

Browse files
fix(components): do not optimize animated images
Some contents use images with `.gif` extension. Those images should not be optimized according to Next warnings.
1 parent 28d3264 commit 10a4c1b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.cspell/project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ stylelint
2929
svgr
3030
thematics
3131
undici
32+
unoptimized

src/components/mdx.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const Img = ({
4646
height={typeof height === 'string' ? Number(height) : height}
4747
src={src}
4848
width={typeof width === 'string' ? Number(width) : width}
49+
unoptimized={src.endsWith('.gif')}
4950
/>
5051
);
5152

src/utils/helpers/pages.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ export const getPostsWithUrl = (posts: ArticlePreview[]): PostData[] =>
5252
posts.map(({ id, intro, meta, slug, title, ...post }) => {
5353
return {
5454
...post,
55-
cover: meta.cover ? <NextImage {...meta.cover} /> : undefined,
55+
cover: meta.cover ? (
56+
<NextImage
57+
{...meta.cover}
58+
unoptimized={meta.cover.src.endsWith('.gif')}
59+
/>
60+
) : undefined,
5661
excerpt: intro,
5762
heading: title,
5863
id,

0 commit comments

Comments
 (0)