Skip to content

Commit 168aead

Browse files
committed
Move Social Cards astro layout to own directory, along with notes on current implementation
1 parent 0542a64 commit 168aead

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎@types/cssmodule.d.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.module.css' {
2+
const classes: Record<string, string>
3+
export default classes
4+
}

‎_TODO.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# TODO
22

3+
## Analytics
4+
5+
Vercel Analytics
6+
37
## Themepicker tooltips, extra themes
48

59
- Add additional themes
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# How cards are provided currently
2+
3+
index.astro is included in every layout; it renders Meta.astro, which in turn renders Social.astro.
4+
5+
Social.astro builds the full Open Graph + Twitter meta block. It calls getSocialMetadata from index.ts with the current page title, description, slug, and optional image.
6+
7+
getSocialMetadata normalizes the site base URL, then either uses the page's explicit image (if provided) or calls getSocialImage. That helper composes a URL to the serverless endpoint index.ts.
8+
9+
The /api/social-card endpoint accepts title, description, slug, etc., and returns an HTML template styled as our share card; that URL is what ends up in og:image / twitter:image. Social platforms fetch the URL declared in those meta tags, so the card they render comes entirely from the metadata emitted by Head/Social.
10+
11+
The Social/Shares component (Shares.astro) doesn't generate cards; it just renders on-page share buttons. Each platform config in platforms.ts produces a share URL (or, for Mastodon, opens our modal) using the already-published page URL and text. Those buttons rely on the card metadata above so platforms show the correct preview when the shared link is opened.
12+
Next steps (optional)
13+
14+
If you need richer cards (dynamic screenshots, branded variants), enhance /api/social-card or point getSocialImage at an external image generator.
15+
To customize per-page artwork, pass an image prop from frontmatter so Head/Social uses that instead of the auto-generated URL.

src/components/Social/Shares/SocialCard.astro renamed to src/components/Social/Cards/index.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const { title, description, publishedDate } = Astro.props
1717
---
1818

1919
<div
20-
class="relative flex flex-col justify-center items-center overflow-hidden rounded-xl text-white font-sans box-border bg-gradient-to-br from-slate-900 to-blue-600 w-[1200px] h-[630px] p-16 max-w-full aspect-[1200/630] xl:w-full"
20+
class="relative flex flex-col justify-center items-center overflow-hidden rounded-xl text-white font-sans box-border bg-linear-to-br from-slate-900 to-blue-600 w-[1200px] h-[630px] p-16 max-w-full aspect-1200/630 xl:w-full"
2121
>
2222
<!-- Decorative elements -->
2323
<div class="absolute inset-0 pointer-events-none">
@@ -28,14 +28,14 @@ const { title, description, publishedDate } = Astro.props
2828
</div>
2929

3030
<!-- Content -->
31-
<div class="text-center z-[2] max-w-[1000px]">
31+
<div class="text-center z-2 max-w-[1000px]">
3232
<h1 class="font-medium text-white leading-tight text-6xl mb-8">{title}</h1>
3333
{description && <p class="leading-relaxed opacity-90 text-2xl mb-4">{description}</p>}
3434
{publishedDate && <div class="opacity-80 italic text-xl">Published on {publishedDate}</div>}
3535
</div>
3636

3737
<!-- Brand -->
38-
<div class="absolute font-bold opacity-80 z-[2] bottom-10 right-10 text-3xl">
38+
<div class="absolute font-bold opacity-80 z-2 bottom-10 right-10 text-3xl">
3939
Webstack Builders
4040
</div>
4141
</div>

0 commit comments

Comments
 (0)