Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Redesign docs/marketing OG images with brand identity (#1079)

Goldflag9cf03cc9f7f2
diff --git a/docs/src/app/[locale]/(home)/tools/page-speed-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/page-speed-calculator/page.tsx
index 5023e35dd..d5a4dd0e7 100644
--- a/docs/src/app/[locale]/(home)/tools/page-speed-calculator/page.tsx
+++ b/docs/src/app/[locale]/(home)/tools/page-speed-calculator/page.tsx
@@ -13,20 +13,11 @@ export const metadata: Metadata = {
type: "website",
url: "https://rybbit.com/tools/page-speed-calculator",
siteName: "Rybbit",
- images: [
- {
- url: "https://rybbit.com/og-image.png",
- width: 1200,
- height: 630,
- alt: "Page Speed Calculator",
- },
- ],
},
twitter: {
card: "summary_large_image",
title: "Free Page Speed Calculator | Website Load Time Impact Calculator",
description: "Calculate how page load time affects your conversions and revenue.",
- images: ["https://rybbit.com/og-image.png"],
},
alternates: {
canonical: "https://rybbit.com/tools/page-speed-calculator",
diff --git a/docs/src/app/[locale]/blog/[...slug]/page.tsx b/docs/src/app/[locale]/blog/[...slug]/page.tsx
index e93356e8e..86cf9f62b 100644
--- a/docs/src/app/[locale]/blog/[...slug]/page.tsx
+++ b/docs/src/app/[locale]/blog/[...slug]/page.tsx
@@ -9,6 +9,7 @@ import { Pre } from "fumadocs-ui/components/codeblock";
import Script from "next/script";
import { CTASection } from "@/components/CTASection";
import { GridCrosses } from "@/components/GridCrosses";
+import { createOGImageUrl } from "@/lib/metadata";
export function generateStaticParams() {
return blogSource.getPages().map(page => ({
@@ -23,7 +24,8 @@ export async function generateMetadata(props: { params: Promise<{ slug: string[]
const url = `https://rybbit.com/blog/${params.slug.join("/")}`;
const publishedTime = page.data.date ? new Date(page.data.date).toISOString() : undefined;
- const ogImage = page.data.image || "/opengraph-image.png";
+ const ogImage =
+ page.data.image || createOGImageUrl(page.data.title, page.data.description, "Blog").url;
return {
title: page.data.title,
diff --git a/docs/src/app/og-image/route.tsx b/docs/src/app/og-image/route.tsx
deleted file mode 100644
index 4044c6829..000000000
--- a/docs/src/app/og-image/route.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import { ImageResponse } from 'next/og';
-import { readFile } from 'node:fs/promises';
-import { join } from 'node:path';
-import { generateOGImage } from '@/app/og/[...slug]/generate';
-
-const logoBase64 = readFile(
- join(process.cwd(), 'public/rybbit/horizontal_white.png'),
-).then((buf) => `data:image/png;base64,${buf.toString('base64')}`);
-
-async function loadInterFont(
- weight: 400 | 700,
-): Promise<ArrayBuffer> {
- const css = await fetch(
- `https://fonts.googleapis.com/css2?family=Inter:wght@${weight}&display=swap`,
- ).then((res) => res.text());
-
- const match = css.match(/src: url\((.+?)\) format\('(opentype|truetype|woff2?)'\)/);
- if (!match?.[1]) {
- throw new Error(`Could not load Inter ${weight} font`);
- }
-
- return fetch(match[1]).then((res) => res.arrayBuffer());
-}
-
-export async function GET(req: Request) {
- const { searchParams } = new URL(req.url);
- const title = searchParams.get('title') ?? 'Rybbit';
- const description = searchParams.get('description') ?? undefined;
-
- const [interRegular, interBoldFont, logoSrc] = await Promise.all([
- loadInterFont(400),
- loadInterFont(700),
- logoBase64,
- ]);
-
- return new ImageResponse(
- generateOGImage({
- title,
- description,
- logoSrc,
- }),
- {
- width: 1200,
- height: 630,
- fonts: [
- {
- name: 'Inter',
- data: interRegular,
- weight: 400,
- style: 'normal',
- },
- {
- name: 'Inter',
- data: interBoldFont,
- weight: 700,
- style: 'normal',
- },
- ],
- },
- );
-}
diff --git a/docs/src/app/og/[...slug]/generate.tsx b/docs/src/app/og/[...slug]/generate.tsx
index 8a95e1d73..a0ea76929 100644
--- a/docs/src/app/og/[...slug]/generate.tsx
+++ b/docs/src/app/og/[...slug]/generate.tsx
@@ -7,6 +7,17 @@ interface GenerateOGImageProps {
label?: string;
}
+function titleFontSize(title: string): number {
+ if (title.length <= 24) return 84;
+ if (title.length <= 40) return 72;
+ if (title.length <= 60) return 62;
+ return 54;
+}
+
+// Jagged up-and-to-the-right series, echoing the product's sparklines
+const CHART_POINTS =
+ '0,178 60,150 120,168 180,122 240,146 300,98 360,128 420,84 480,110 540,64 600,94 660,50 720,80 780,58 840,90 900,44 960,70 1020,34 1080,56 1140,22 1200,40';
+
export function generateOGImage({
title,
description,
@@ -18,68 +29,133 @@ export function generateOGImage({
style={{
display: 'flex',
flexDirection: 'column',
- justifyContent: 'space-between',
+ position: 'relative',
width: '100%',
height: '100%',
- padding: '80px',
- backgroundColor: 'rgb(10, 10, 10)',
+ padding: '64px 72px',
+ backgroundColor: 'rgb(13, 13, 13)',
color: 'white',
fontFamily: 'Inter',
+ border: '1px solid rgb(38, 38, 38)',
}}
>
+ {/* Emerald glow, top-left */}
+ <div
+ style={{
+ position: 'absolute',
+ top: 0,
+ left: 0,
+ width: '1200px',
+ height: '630px',
+ background:
+ 'radial-gradient(ellipse 800px 500px at 8% -10%, rgba(16, 185, 129, 0.13), transparent 65%)',
+ }}
+ />
+ {/* Periwinkle glow, bottom-right */}
+ <div
+ style={{
+ position: 'absolute',
+ top: 0,
+ left: 0,
+ width: '1200px',
+ height: '630px',
+ background:
+ 'radial-gradient(ellipse 700px 400px at 95% 110%, rgba(179, 191, 255, 0.10), transparent 65%)',
+ }}
+ />
+ {/* Data-line motif along the bottom */}
+ <svg
+ width="1200"
+ height="220"
+ viewBox="0 0 1200 220"
+ style={{ position: 'absolute', bottom: 0, left: 0 }}
+ >
+ <defs>
+ <linearGradient id="area" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0%" stopColor="rgb(179, 191, 255)" stopOpacity="0.16" />
+ <stop offset="100%" stopColor="rgb(179, 191, 255)" stopOpacity="0" />
+ </linearGradient>
+ </defs>
+ <polygon
+ points={`0,220 ${CHART_POINTS} 1200,220`}
+ fill="url(#area)"
+ />
+ <polyline
+ points={CHART_POINTS}
+ fill="none"
+ stroke="rgb(179, 191, 255)"
+ strokeWidth="3"
+ strokeOpacity="0.45"
+ strokeLinejoin="round"
+ />
+ </svg>
+
+ {/* Header: logo + label chip */}
<div
style={{
display: 'flex',
- flexDirection: 'column',
- gap: '20px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ width: '100%',
}}
>
- <div
- style={{
- fontSize: title.length > 40 ? 60 : 76,
- fontWeight: 700,
- lineHeight: 1.1,
- letterSpacing: '-0.02em',
- color: 'white',
- }}
- >
- {title}
- </div>
- {description ? (
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+ <img src={logoSrc} height="44" style={{ height: '44px' }} alt="" />
+ {label ? (
<div
style={{
- fontSize: description.length > 100 ? 36 : 42,
- lineHeight: 1.4,
- color: 'rgb(163, 163, 163)',
- maxWidth: '900px',
+ display: 'flex',
+ alignItems: 'center',
+ fontSize: 24,
+ fontWeight: 400,
+ color: 'rgb(52, 211, 153)',
+ backgroundColor: 'rgba(16, 185, 129, 0.12)',
+ padding: '8px 18px',
+ borderRadius: '8px',
}}
>
- {description}
+ {label}
</div>
) : null}
</div>
+
+ {/* Title + description, anchored to the lower half above the chart */}
<div
style={{
display: 'flex',
- alignItems: 'center',
+ flexDirection: 'column',
+ flexGrow: 1,
+ justifyContent: 'center',
gap: '24px',
+ paddingBottom: '48px',
}}
>
- {/* eslint-disable-next-line @next/next/no-img-element */}
- <img
- src={logoSrc}
- height="40"
- style={{ height: '40px' }}
- alt=""
- />
- {label ? (
+ <div
+ style={{
+ display: 'block',
+ lineClamp: 3,
+ fontSize: titleFontSize(title),
+ fontWeight: 700,
+ lineHeight: 1.12,
+ letterSpacing: '-0.025em',
+ color: 'white',
+ maxWidth: '1000px',
+ }}
+ >
+ {title}
+ </div>
+ {description ? (
<div
style={{
- fontSize: 28,
- color: 'rgb(115, 115, 115)',
+ display: 'block',
+ lineClamp: 2,
+ fontSize: 32,
+ lineHeight: 1.5,
+ color: 'rgb(170, 170, 170)',
+ maxWidth: '880px',
}}
>
- {label}
+ {description}
</div>
) : null}
</div>
diff --git a/docs/src/app/og/[...slug]/route.tsx b/docs/src/app/og/[...slug]/route.tsx
index 665ffd042..a9cfefbaa 100644
--- a/docs/src/app/og/[...slug]/route.tsx
+++ b/docs/src/app/og/[...slug]/route.tsx
@@ -6,7 +6,7 @@ import { notFound } from 'next/navigation';
import { generateOGImage } from './generate';
const logoBase64 = readFile(
- join(process.cwd(), 'public/rybbit/horizontal_white.png'),
+ join(process.cwd(), 'public/rybbit/horizontal_for dark BG.png'),
).then((buf) => `data:image/png;base64,${buf.toString('base64')}`);
async function loadInterFont(