The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(kb): og image (#52096)
Anthony Lio29ee3dcaa01c
diff --git a/apps/kb/src/layouts/Layout.astro b/apps/kb/src/layouts/Layout.astroindex b32a42a7b1e..227b9bb4ad5 100644--- a/apps/kb/src/layouts/Layout.astro+++ b/apps/kb/src/layouts/Layout.astro@@ -22,6 +22,10 @@ const navTopics = getListedTopics({}).map((topic) => topic.name)const faviconRoute = import.meta.env.DEV ? '/favicon/local' : '/favicon'const canonicalHref = canonicalUrl(Astro.url.pathname)+const ogImage = title+ ? `https://obuldanrptloktxcffvn.supabase.co/functions/v1/og-images?site=kb&title=${encodeURIComponent(title)}&description=${encodeURIComponent(description ?? 'undefined')}`+ : 'https://supabase.com/docs/img/supabase-og-image.png'+const pageTitle = title ? `${title} | Supabase Knowledge Base` : 'Supabase Knowledge Base'---<!doctype html>@@ -60,7 +64,17 @@ const canonicalHref = canonicalUrl(Astro.url.pathname)/><link rel="canonical" href={canonicalHref} /><link rel="sitemap" href={`${import.meta.env.BASE_URL}/sitemap-index.xml`} />- <title>{title ? `${title} | Supabase Knowledge Base` : 'Supabase Knowledge Base'}</title>+ <title>{pageTitle}</title>+ <meta property="og:type" content="article" />+ <meta property="og:title" content={pageTitle} />+ {description && <meta property="og:description" content={description} />}+ <meta property="og:url" content={canonicalHref} />+ <meta property="og:image" content={ogImage} />+ <meta property="og:image:alt" content={title ?? pageTitle} />+ <meta name="twitter:card" content="summary_large_image" />+ <meta name="twitter:site" content="@supabase" />+ <meta name="twitter:creator" content="@supabase" />+ <meta name="twitter:image" content={ogImage} />{jsonLd && <script type="application/ld+json" is:inline set:html={serializeJsonLd(jsonLd)} />}</head><body class="flex min-h-dvh flex-col">diff --git a/supabase/functions/og-images/README.md b/supabase/functions/og-images/README.mdindex 60679f210f1..318e6a9db3a 100644--- a/supabase/functions/og-images/README.md+++ b/supabase/functions/og-images/README.md@@ -6,7 +6,7 @@ Generate OG Images for the sites at supabase.To use the og image generator, you will need to visit the site with the following parameters:-`site`: indicating which site you want to generate an image for. Currently, the only available option is docs.+`site`: indicating which site you want to generate an image for. One of `docs`, `kb`, `customers` or `events`.`title`: representing the title of the image you want to generate.diff --git a/supabase/functions/og-images/component/Docs.tsx b/supabase/functions/og-images/component/Docs.tsxindex 7528b8d42a7..06dc52a5d70 100644--- a/supabase/functions/og-images/component/Docs.tsx+++ b/supabase/functions/og-images/component/Docs.tsx@@ -5,10 +5,11 @@ type Props = {title: stringdescription: stringicon?: string | null+ label: string}const Docs = (props: Props) => {- const { type, title, description, icon } = props+ const { type, title, description, icon, label } = propslet typeName: string | undefined = type?.replace(/-/g, ' ')@@ -67,7 +68,7 @@ const Docs = (props: Props) => {height={34}/><span tw="text-2xl font-normal text-[#3ecf8e] ml-4" style={{ fontFamily: 'SourceCode' }}>- DOCS+ {label}</span></div></div>diff --git a/supabase/functions/og-images/handler.tsx b/supabase/functions/og-images/handler.tsxindex 78fb5a87eff..199add266e9 100644--- a/supabase/functions/og-images/handler.tsx+++ b/supabase/functions/og-images/handler.tsx@@ -62,6 +62,7 @@ export async function handler(req: Request) {switch (site) {case 'docs':+ case 'kb':return new ImageResponse((<Docs@@ -69,6 +70,7 @@ export async function handler(req: Request) {description={description !== 'undefined' ? description : ''}type={type}icon={icon}+ label={site.toUpperCase()}/>),{