diff --git a/app/public/assets/policyengine-social-preview.png b/app/public/assets/policyengine-social-preview.png new file mode 100644 index 000000000..e39ae2ac4 Binary files /dev/null and b/app/public/assets/policyengine-social-preview.png differ diff --git a/app/website.html b/app/website.html index 892ff441d..3f0308fd9 100644 --- a/app/website.html +++ b/app/website.html @@ -32,8 +32,11 @@ /> + + + @@ -48,8 +51,9 @@ /> +
diff --git a/website/src/__tests__/layout/root-layout.test.tsx b/website/src/__tests__/layout/root-layout.test.tsx new file mode 100644 index 000000000..d7b7fc463 --- /dev/null +++ b/website/src/__tests__/layout/root-layout.test.tsx @@ -0,0 +1,40 @@ +import { describe, expect, test } from "vitest"; +import { metadata } from "../../app/layout"; + +const SOCIAL_PREVIEW_IMAGE = "/assets/policyengine-social-preview.png"; + +describe("RootLayout metadata", () => { + test("includes default social preview metadata", () => { + expect(metadata.openGraph).toEqual( + expect.objectContaining({ + title: "PolicyEngine", + description: metadata.description, + siteName: "PolicyEngine", + type: "website", + images: [ + { + url: SOCIAL_PREVIEW_IMAGE, + width: 1200, + height: 630, + alt: "PolicyEngine", + }, + ], + }), + ); + + expect(metadata.twitter).toEqual( + expect.objectContaining({ + card: "summary_large_image", + site: "@ThePolicyEngine", + title: "PolicyEngine", + description: metadata.description, + images: [ + { + url: SOCIAL_PREVIEW_IMAGE, + alt: "PolicyEngine", + }, + ], + }), + ); + }); +}); diff --git a/website/src/app/layout.tsx b/website/src/app/layout.tsx index 41aaa2447..5382aaf85 100644 --- a/website/src/app/layout.tsx +++ b/website/src/app/layout.tsx @@ -5,6 +5,14 @@ import { SpeedInsights } from "@vercel/speed-insights/next"; import "./globals.css"; const GA_MEASUREMENT_ID = "G-2YHG89FY0N"; +const SITE_DESCRIPTION = + "Free, open-source tools to understand tax and benefit policies. Calculate your taxes and benefits, or analyze policy reforms."; +const SOCIAL_PREVIEW_IMAGE = { + url: "/assets/policyengine-social-preview.png", + width: 1200, + height: 630, + alt: "PolicyEngine", +}; export const metadata: Metadata = { metadataBase: new URL("https://www.policyengine.org"), @@ -12,11 +20,29 @@ export const metadata: Metadata = { template: "%s | PolicyEngine", default: "PolicyEngine", }, - description: - "Free, open-source tools to understand tax and benefit policies. Calculate your taxes and benefits, or analyze policy reforms.", + description: SITE_DESCRIPTION, icons: { icon: "/favicon.svg", }, + openGraph: { + title: "PolicyEngine", + description: SITE_DESCRIPTION, + siteName: "PolicyEngine", + type: "website", + images: [SOCIAL_PREVIEW_IMAGE], + }, + twitter: { + card: "summary_large_image", + site: "@ThePolicyEngine", + title: "PolicyEngine", + description: SITE_DESCRIPTION, + images: [ + { + url: SOCIAL_PREVIEW_IMAGE.url, + alt: SOCIAL_PREVIEW_IMAGE.alt, + }, + ], + }, }; export default function RootLayout({