| 1 | import { ImageResponse } from "next/og"; |
| 2 | import { |
| 3 | allEnglishWritings, |
| 4 | allGermanWritings, |
| 5 | } from "@/.content-collections/generated"; |
| 6 | import { |
| 7 | formatDate, |
| 8 | loadOgAssets, |
| 9 | OgFrame, |
| 10 | OG_HANDLE, |
| 11 | OG_NAME, |
| 12 | OG_SIZE, |
| 13 | truncate, |
| 14 | } from "@/lib/og"; |
| 15 | import en from "@/translations/en.json |
| 16 | import de from "@/translations/de.json |
| 17 | |
| 18 | export const runtime = |
| 19 | export const contentType = |
| 20 | export const size = |
| 21 | export const alt = |
| 22 | |
| 23 | const MESSAGES: Record |
| 24 | |
| 25 | const PREVIEW_COUNT = 3 |
| 26 | |
| 27 | export default async function |
| 28 | params: Promise |
| 29 | }) { |
| 30 | const { locale |
| 31 | const messages = |
| 32 | |
| 33 | const title = |
| 34 | const description = |
| 35 | |
| 36 | const latest = |
| 37 | .sort((a, |
| 38 | .slice(0, PREVIEW_COUNT |
| 39 | .map((writing) |
| 40 | title: truncate(writing |
| 41 | date: formatDate(writing |
| 42 | })); |
| 43 | |
| 44 | const boldText = |
| 45 | const regularText = |
| 46 | OG_HANDLE + |
| 47 | description + |
| 48 | latest.map((w |
| 49 | "EnglishDeutsch"; |
| 50 | |
| 51 | const [fonts, |
| 52 | |
| 53 | return new ImageResponse |
| 54 | ( |
| 55 | <OgFrame avatar={ |
| 56 | <div |
| 57 | style={{ display: |
| 58 | > |
| 59 | <span |
| 60 | style={{ |
| 61 | fontSize: 72, |
| 62 | fontWeight: 700, |
| 63 | color: "#ffffff", |
| 64 | lineHeight: 1.1, |
| 65 | }} |
| 66 | > |
| 67 | {title} |
| 68 | </span> |
| 69 | <span |
| 70 | style={{ |
| 71 | fontSize: 30, |
| 72 | color: "#9ca3af", |
| 73 | lineHeight: 1.4, |
| 74 | marginTop: 18, |
| 75 | }} |
| 76 | > |
| 77 | {description} |
| 78 | </span> |
| 79 | |
| 80 | <div |
| 81 | style={{ |
| 82 | display: "flex", |
| 83 | flexDirection: "column", |
| 84 | marginTop: 34, |
| 85 | borderTop: "2px solid #262626", |
| 86 | }} |
| 87 | > |
| 88 | {latest.map(( |
| 89 | <div |
| 90 | key={writing.title |
| 91 | style={{ |
| 92 | display: "flex", |
| 93 | flexDirection: "row", |
| 94 | alignItems: "baseline", |
| 95 | justifyContent: "space-between", |
| 96 | padding: "15px 0", |
| 97 | ...(index === |
| 98 | ? {} |
| 99 | : { borderBottom: "2px solid #262626 |
| 100 | }} |
| 101 | > |
| 102 | <span style={{ |
| 103 | {writing.title} |
| 104 | </span> |
| 105 | <span style={{ |
| 106 | {writing.date} |
| 107 | </span> |
| 108 | </div> |
| 109 | ))} |
| 110 | </div> |
| 111 | </div> |
| 112 | </OgFrame> |
| 113 | ), |
| 114 | { |
| 115 | ...size, |
| 116 | ...(fonts ? |
| 117 | }, |
| 118 | ); |
| 119 | } |