Skip to content

Commit 3b0e606

Browse files
committed
fix: better responsive image sizes and structured data image
1 parent dc0845d commit 3b0e606

File tree

7 files changed

+8
-6
lines changed

7 files changed

+8
-6
lines changed

β€Žapp/(articles)/ArticlePreview.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import Picture from "next-export-optimize-images/image";
3+
import Picture from "next-export-optimize-images/picture";
44
import type { StaticImageData } from "next/image";
55
import Link from "next/link";
66
import React, { useContext, useState } from "react";
@@ -66,7 +66,7 @@ export default function ArticlePreview(props: PreviewProps) {
6666
>
6767
<Picture
6868
className="absolute inset-0 z-0 h-full w-full rounded-xl object-cover"
69-
sizes="100vw, (min-width: 768px) 50vw, (min-width: 1024px) 33vw"
69+
sizes="(min-width: 1024px) 33vw, (min-width: 768px) 50vw, 100vw"
7070
src={props.cover}
7171
alt={props.title}
7272
width={1600}

β€Žapp/(articles)/ctf/[slug]/page.tsxβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export default async function ArticlePage({
113113
gender: author.gender,
114114
email: author.email,
115115
sameAs: author.extraLinks?.map((link) => link.toString()),
116+
image: `${baseUrl}/covers/ctf/${slug}/${metadata.cover}`,
116117
},
117118
};
118119

β€Žapp/(articles)/ctf/page.tsxβ€Ž

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { authors, list, loadMetadata } from "..";
2-
import { StaticImageData } from "next/image";
2+
import path from "path";
33

44
import "./article-listing.css";
55

@@ -29,11 +29,10 @@ export default async function Articles() {
2929
let articles: PreviewProps[] = await Promise.all(
3030
pages.map(async (page): Promise<PreviewProps> => {
3131
const metadata = await loadMetadata("ctf", page.slug);
32-
const image = await import(`@/articles/ctf/${page.slug}/cover.png`);
3332
return {
3433
title: metadata.title,
3534
summary: metadata.summary,
36-
cover: image.default as StaticImageData,
35+
cover: path.join("/covers", "ctf", page.slug, metadata.cover),
3736
coverAlt: metadata.coverAlt,
3837
author: `${authors[metadata.author].name} (${metadata.author})`,
3938
date: new Date(metadata.publishedAt).toLocaleDateString("en-US", {

β€Žapp/(articles)/index.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const ArticleMetadata = z.object({
2121
.nonempty()
2222
// https://ogtester.com/blog/what-is-maximum-length-of-og-title-and-og-description
2323
.max(150, "Summary should be less than 150 characters"),
24+
cover: z.string().nonempty(),
2425
coverAlt: z.string().nonempty(),
2526
author: z.enum(["renbou", "qwqoro", "slonser"]),
2627
publishedAt: z.string().datetime(), // exposed in OpenGraph meta

β€Žarticles/ctf/blazctf-2024-solalloc-writeup/metadata.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"title": "Draining a Solana Vault via Pointer Corruption on BlazCTF",
33
"summary": "Step-by-step analysis and exploitation of a binary vulnerability in a Solana smart contract. Writeup for the Solalloc task from BlazCTF 2024.",
4+
"cover": "exploding-vault-with-blazctf-dinosaur.png",
45
"coverAlt": "Hand pointing at exploding vault with BlazCTF-themed pixelated T-Rex",
56
"author": "renbou",
67
"publishedAt": "2024-11-23T10:00:00Z",

β€Žnext.config.mjsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import withExportImages from "next-export-optimize-images";
88
const nextConfig = {
99
output: "export",
1010
images: {
11-
deviceSizes: [384, 768, 1024, 2048],
11+
deviceSizes: [384, 768, 1200, 2048],
1212
imageSizes: [128, 256],
1313
},
1414
reactStrictMode: false,
File renamed without changes.

0 commit comments

Comments
Β (0)