Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): use README artwork for default social cards

Gus4ded934340cb
diff --git a/src/web/public/social/readme-card-58c75311e5ba.png b/src/web/public/social/readme-card-58c75311e5ba.png
new file mode 100644
index 000000000..4efcb83e2
Binary files /dev/null and b/src/web/public/social/readme-card-58c75311e5ba.png differ
diff --git a/src/web/src/app/(home)/opengraph-image.tsx b/src/web/src/app/(home)/opengraph-image.tsx
deleted file mode 100644
index d66daf2bf..000000000
--- a/src/web/src/app/(home)/opengraph-image.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { BRAND_SLOGAN, BRAND_TITLE } from "@/lib/brand-copy";
-import {
- OG_IMAGE_CONTENT_TYPE,
- OG_IMAGE_SIZE,
- renderOgImage,
-} from "@/app/_og/render-og-image";
-
-export const alt = BRAND_TITLE;
-export const size = OG_IMAGE_SIZE;
-export const contentType = OG_IMAGE_CONTENT_TYPE;
-
-export default function OpenGraphImage() {
- return renderOgImage(BRAND_SLOGAN);
-}
diff --git a/src/web/src/app/(home)/page.tsx b/src/web/src/app/(home)/page.tsx
index 58b377b99..f38714d30 100644
--- a/src/web/src/app/(home)/page.tsx
+++ b/src/web/src/app/(home)/page.tsx
@@ -6,6 +6,7 @@ import {
} from "@/components/home/landing-content";
import { LandingPage } from "@/components/home/landing-page";
import { getSession } from "@/lib/session";
+import { SITE_OG_IMAGE } from "@/lib/seo/site-metadata";
const title = LANDING_META_TITLE;
const description = LANDING_META_DESCRIPTION;
@@ -19,12 +20,14 @@ export const metadata: Metadata = {
title,
description,
url: "https://alook.ai",
+ images: [SITE_OG_IMAGE],
},
twitter: {
card: "summary_large_image",
site: "@alook_ai",
title,
description,
+ images: [SITE_OG_IMAGE],
},
};
diff --git a/src/web/src/app/(home)/twitter-image.tsx b/src/web/src/app/(home)/twitter-image.tsx
deleted file mode 100644
index 8f726ce33..000000000
--- a/src/web/src/app/(home)/twitter-image.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { alt, contentType, default, size } from "./opengraph-image";
diff --git a/src/web/src/app/_og/homepage-social-image.test.ts b/src/web/src/app/_og/homepage-social-image.test.ts
new file mode 100644
index 000000000..767c5927f
--- /dev/null
+++ b/src/web/src/app/_og/homepage-social-image.test.ts
@@ -0,0 +1,56 @@
+import { existsSync, readFileSync } from "node:fs"
+import { createHash } from "node:crypto"
+import sharp from "sharp"
+import { describe, expect, it } from "vitest"
+import { SITE_OG_IMAGE, SITE_OG_IMAGE_URL, siteMetadata } from "@/lib/seo/site-metadata"
+
+const home = new URL("../(home)/", import.meta.url)
+const banner = new URL("../../../../../assets/readme/banner.png", import.meta.url)
+const card = new URL(`../../../public${SITE_OG_IMAGE_URL}`, import.meta.url)
+const background = { r: 244, g: 249, b: 233 }
+
+describe("homepage social images", () => {
+ it("serves the same static 1200 by 630 card for Open Graph and Twitter", async () => {
+ const og = readFileSync(card)
+
+ expect(SITE_OG_IMAGE_URL).toContain(createHash("sha256").update(og).digest("hex").slice(0, 12))
+ expect(siteMetadata.openGraph).toMatchObject({ images: [SITE_OG_IMAGE] })
+ expect(siteMetadata.twitter).toMatchObject({ images: [SITE_OG_IMAGE_URL] })
+ expect(await sharp(og).metadata()).toMatchObject({ format: "png", width: 1200, height: 630 })
+ expect(og.byteLength).toBeLessThan(5 * 1024 * 1024)
+ expect(SITE_OG_IMAGE.alt).toBe("Alook — Share your agents with people you trust")
+ expect(readFileSync(new URL("page.tsx", home), "utf8").match(/images: \[SITE_OG_IMAGE\]/g)).toHaveLength(2)
+ expect(existsSync(new URL("opengraph-image.tsx", home))).toBe(false)
+ expect(existsSync(new URL("twitter-image.tsx", home))).toBe(false)
+ })
+
+ it("retains the complete current README banner, including its text and paper", async () => {
+ const readme = readFileSync(new URL("../../../../../README.md", import.meta.url), "utf8")
+ expect(readme.match(/<img\s+src="([^"]+)"/)?.[1]).toBe("./assets/readme/banner.png")
+ const expected = await sharp(readFileSync(banner))
+ .resize({ width: 1200 })
+ .flatten({ background })
+ .removeAlpha()
+ .raw()
+ .toBuffer({ resolveWithObject: true })
+ const top = Math.floor((630 - expected.info.height) / 2)
+ const image = sharp(readFileSync(card))
+ const retained = await image.clone()
+ .extract({ left: 0, top, width: 1200, height: expected.info.height })
+ .removeAlpha()
+ .raw()
+ .toBuffer()
+
+ expect(retained.equals(expected.data)).toBe(true)
+ const padding = await image.clone()
+ .extract({ left: 0, top: 0, width: 1200, height: top })
+ .removeAlpha()
+ .raw()
+ .toBuffer()
+ for (let index = 0; index < padding.length; index += 3) {
+ if (padding[index] !== background.r || padding[index + 1] !== background.g || padding[index + 2] !== background.b) {
+ throw new Error("The README banner must be surrounded by its original pale green background")
+ }
+ }
+ })
+})
diff --git a/src/web/src/app/og/route.test.ts b/src/web/src/app/og/route.test.ts
new file mode 100644
index 000000000..86307793c
--- /dev/null
+++ b/src/web/src/app/og/route.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from "vitest"
+import { SITE_OG_IMAGE_URL } from "@/lib/seo/site-metadata"
+import { GET } from "./route"
+
+describe("legacy brand image", () => {
+ it.each(["https://alook.ai", "http://localhost:3000"])("uses the new card on %s", (origin) => {
+ const response = GET(new Request(`${origin}/og?title=obsolete&image=https://example.com/private`))
+
+ expect(response.status).toBe(308)
+ expect(response.headers.get("location")).toBe(`${origin}${SITE_OG_IMAGE_URL}`)
+ })
+})
diff --git a/src/web/src/app/og/route.tsx b/src/web/src/app/og/route.tsx
index 79c947dc3..2f707021d 100644
--- a/src/web/src/app/og/route.tsx
+++ b/src/web/src/app/og/route.tsx
@@ -1,16 +1,9 @@
-import { BRAND_SLOGAN } from "@/lib/brand-copy";
-import { renderOgImage } from "@/app/_og/render-og-image";
+import { SITE_OG_IMAGE_URL } from "@/lib/seo/site-metadata";
/**
- * Fixed compatibility image for metadata inherited from the root layout.
- * Query parameters are intentionally ignored; route-owned image files provide
- * every page-specific title.
+ * Legacy brand-image URL; page-specific images retain their own routes.
+ * Query parameters cannot change the shared brand card.
*/
-export async function GET() {
- try {
- return await renderOgImage(BRAND_SLOGAN);
- } catch (error) {
- const message = error instanceof Error ? error.message : String(error);
- return new Response(`OG generation failed: ${message}`, { status: 500 });
- }
+export function GET(request: Request) {
+ return Response.redirect(new URL(SITE_OG_IMAGE_URL, request.url), 308);
}
diff --git a/src/web/src/components/home/landing-content.test.ts b/src/web/src/components/home/landing-content.test.ts
index 88e496970..fbab1960f 100644
--- a/src/web/src/components/home/landing-content.test.ts
+++ b/src/web/src/components/home/landing-content.test.ts
@@ -263,7 +263,8 @@ describe("landing content contract", () => {
expect(signInClient).not.toContain("Bring your own workspaces")
expect(communityLayout).toContain("await getSession()")
expect(communityLayoutClient).toContain('<SignupTracker redirectTo="/c/me/machines" />')
- expect(ogRoute).toContain("renderOgImage(BRAND_SLOGAN)")
+ expect(ogRoute).toContain("SITE_OG_IMAGE_URL")
+ expect(ogRoute).toContain("Response.redirect")
expect(ogRoute).not.toContain("searchParams")
expect(ogRenderer).toContain('await getCloudflareContext({ async: true })')
expect(ogRenderer).toContain('env.ASSETS')
diff --git a/src/web/src/lib/seo/site-metadata.test.ts b/src/web/src/lib/seo/site-metadata.test.ts
index 41a7fe50d..7cebf6024 100644
--- a/src/web/src/lib/seo/site-metadata.test.ts
+++ b/src/web/src/lib/seo/site-metadata.test.ts
@@ -11,7 +11,7 @@ import {
describe("canonical site metadata", () => {
it("keeps the shared main and Blog shell defaults in one contract", () => {
expect(SITE_URL).toBe("https://alook.ai")
- expect(SITE_OG_IMAGE_URL).toBe("/og")
+ expect(SITE_OG_IMAGE_URL).toMatch(/^\/social\/readme-card-[a-f0-9]{12}\.png$/)
expect(siteMetadata.metadataBase).toEqual(new URL(SITE_URL))
expect(siteMetadata.title).toMatchObject({ default: BRAND_TITLE, template: "%s — Alook" })
expect(siteMetadata.description).toBe(BRAND_DESCRIPTION)
diff --git a/src/web/src/lib/seo/site-metadata.ts b/src/web/src/lib/seo/site-metadata.ts
index 4da091948..391aeecd7 100644
--- a/src/web/src/lib/seo/site-metadata.ts
+++ b/src/web/src/lib/seo/site-metadata.ts
@@ -3,7 +3,13 @@ import { BRAND_DESCRIPTION, BRAND_SLOGAN, BRAND_TITLE } from "@/lib/brand-copy";
import { ALOOK_ORGANIZATION } from "@/lib/seo/entities";
export const SITE_URL = "https://alook.ai";
-export const SITE_OG_IMAGE_URL = "/og";
+export const SITE_OG_IMAGE_URL = "/social/readme-card-58c75311e5ba.png";
+export const SITE_OG_IMAGE = {
+ url: SITE_OG_IMAGE_URL,
+ width: 1200,
+ height: 630,
+ alt: BRAND_TITLE,
+};
export const siteViewport: Viewport = {
width: "device-width",
@@ -35,14 +41,7 @@ export const siteMetadata: Metadata = {
title: BRAND_TITLE,
description: BRAND_DESCRIPTION,
url: SITE_URL,
- images: [
- {
- url: SITE_OG_IMAGE_URL,
- width: 1200,
- height: 630,
- alt: BRAND_TITLE,
- },
- ],
+ images: [SITE_OG_IMAGE],
},
twitter: {
card: "summary_large_image",