summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src/components
diff options
context:
space:
mode:
authorJay V <[email protected]>2025-06-27 20:03:17 -0400
committerJay V <[email protected]>2025-06-27 20:03:17 -0400
commit6a7983a4ea9cb4ed6ec93f99f742df5a384cf807 (patch)
tree2f7e3529c9bc0c4fb1e5ea55a4207c89218cfdcf /packages/web/src/components
parent737146fca18af16c05470ed00f0437b96fbff53f (diff)
downloadopencode-6a7983a4ea9cb4ed6ec93f99f742df5a384cf807.tar.gz
opencode-6a7983a4ea9cb4ed6ec93f99f742df5a384cf807.zip
docs: adding more share images
Diffstat (limited to 'packages/web/src/components')
-rw-r--r--packages/web/src/components/Head.astro38
1 files changed, 38 insertions, 0 deletions
diff --git a/packages/web/src/components/Head.astro b/packages/web/src/components/Head.astro
new file mode 100644
index 000000000..36f11c955
--- /dev/null
+++ b/packages/web/src/components/Head.astro
@@ -0,0 +1,38 @@
+---
+import { Base64 } from "js-base64";
+import type { Props } from '@astrojs/starlight/props'
+import Default from '@astrojs/starlight/components/Head.astro'
+import config from '../../config.mjs'
+
+const slug = Astro.url.pathname.replace(/^\//, "").replace(/\/$/, "");
+const {
+ entry: {
+ data: { title },
+ },
+} = Astro.locals.starlightRoute;
+const isDocs = slug.startsWith("docs")
+
+let encodedTitle = '';
+let ogImage = `${config.url}/social-share.png`;
+
+if (isDocs) {
+ // Truncate to fit S3's max key size
+ encodedTitle = encodeURIComponent(
+ Base64.encode(
+ // Convert to ASCII
+ encodeURIComponent(
+ // Truncate to fit S3's max key size
+ title.substring(0, 700)
+ )
+ )
+ );
+ ogImage = `${config.socialCard}/opencode-docs/${encodedTitle}.png`;
+}
+---
+
+<Default {...Astro.props}><slot /></Default>
+
+{ (isDocs || !slug.startsWith("s")) && (
+ <meta property="og:image" content={ogImage} />
+ <meta property="twitter:image" content={ogImage} />
+)}