Skip to content

Per-page social preview cards for docs and blog - #672

Open
jkelleyrtp wants to merge 1 commit into
mainfrom
devin/1789184898-social-preview-cards
Open

jkelleyrtp wants to merge 1 commit into
mainfrom
devin/1789184898-social-preview-cards

Conversation

@jkelleyrtp

Copy link
Copy Markdown
Member

Summary

Links to docs pages and blog posts currently unfurl as the generic homepage card (same <title>, description and opengraph.png on every route). This PR makes every page carry its own metadata and gives docs/blog pages a generated 1200×630 preview image.

samples

Per-route meta (packages/docsite/src/seo.rs) — Head is now driven by PageMeta::for_route(&route):

  • <title>, meta[description], link[canonical], full og:* set (og:url, og:image + width/height/alt, og:site_name, og:type website|article), twitter:* (summary_large_image, @dioxuslabs), and for blog posts article:published_time / article:author.
  • Docs: title "{page} – Dioxus 0.7 Docs"; generic pages ("Overview") get their chapter or SUMMARY part prefixed ("Core Concepts: Overview – …"). Description = first paragraph of the page's markdown (markdown_description, via pulldown-cmark: skips headings/html/code/{{#include}}, ~200 chars).
  • Blog: title/description/date/category come from the existing "Title $ Category $ Date $ Description" SUMMARY format (page_to_meta is now shared and no longer panics on malformed lines). Also fixed introducing-dioxus.md's swapped category/date in SUMMARY.md, which was showing "Release Notes" as the date on the blog list.
  • Old docs versions keep noindex and fall back to the default image; the default image now goes through asset!() so it resolves to the real hashed path (the old hardcoded /assets/static/opengraph.png URL was likely stale).

Generated OG images (packages/docsite/src/og_image.rs, server feature only)

  • Runs as part of the existing server --generate-search-index step in gh-pages.yml, so no workflow changes: writes public/og/<slug>.png for all 0.7 docs pages, blog posts, /blog, /awesome, /deploy (109 images, ~0.1 s each in release).
  • Renders an SVG template with resvg (bundled Inter fonts under packages/docsite/og/fonts, OFL) — dark card with the DNA logo, breadcrumb eyebrow (DOCS · 0.7 · CORE CONCEPTS · BUILDING USER INTERFACES), title (auto-shrinks 76→52px, ≤3 lines), description (≤2 lines, ellipsised). Text is measured with ab_glyph for wrapping; inner breadcrumbs are dropped when the eyebrow doesn't fit.
  • seo::og_image_slug(route) (/learn/0.7/essentials/ui/rsx → learn-0.7-essentials-ui-rsx) is the single source for both the og:image URL and the file name.

Verified locally with the same commands as CI (dx build --web --fullstack true --features fullstack,production --release --ssg then server --generate-search-index): SSG HTML for /, /learn/0.7/essentials/ui/rsx, /blog/release-070 contains each tag exactly once with the expected values, and public/og/ contains 109 PNGs.

To preview cards locally without a full build: OG_PREVIEW_DIR=/tmp/og cargo test -p dioxus_docs_site --features server og_image.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/c3136db61b114f4bba89e1d74f9ed07c
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/c3136db61b114f4bba89e1d74f9ed07c?variant=devin-insiders
Requested by: @jkelleyrtp

@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant