Skip to content

feat: generate Open Graph images and add og: and twitter: metadata#289

Merged
julien-deramond merged 1 commit intomainfrom
main-jd-opengraph-images
Oct 28, 2023
Merged

feat: generate Open Graph images and add og: and twitter: metadata#289
julien-deramond merged 1 commit intomainfrom
main-jd-opengraph-images

Conversation

@julien-deramond
Copy link
Copy Markdown
Member

@julien-deramond julien-deramond commented Oct 28, 2023

Description

This PR supersedes #80

This PR creates Open Graph images based on https://github.com/delucis/astro-og-canvas and Astro's doc implementation.

The idea is to generate images for each Markdown pages in src/content and to use them as Open Graph images. As an example, src/content/articles/can-i-take-this-issue.mdx will have an image generated at public/open-graph/articles/can-i-take-this-issue.png, and so within https://main-branch-openresource-dev-git-main-jd-o-3c43e0-open-resource.vercel.app/articles/can-i-take-this-issue, you'll find <meta property="og:image" content="https://openresource.dev/open-graph/articles/can-i-take-this-issue.png"> (that can be tested via https://main-branch-openresource-dev-git-main-jd-o-3c43e0-open-resource.vercel.app/open-graph/articles/can-i-take-this-issue.png).

While we are at it, we handle all og:* and twitter:* meta tags based on frontmatter data of each page of the website.

However, this technique only works for src/content written in Markdown. Other pages directly as Astro pages can't have generated content like this one as is.

For now, I've created a template in Figma to generate static images for the other pages. I'll create a task after this PR to automatize its generation.

(Note: this PR has needed two more commits afterward to fix some tiny issues: 3a6e082 and e313a5f)

After this PR

Motivation & Context

This change is the first part required to have images displayed when Open {re}Source links are shared on other platforms.

Type of changes

  • New feature (non-breaking change which adds functionality)

Checklist

@julien-deramond julien-deramond added the feature Something can be improved label Oct 28, 2023
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
main-branch-openresource-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2023 1:09pm

@julien-deramond julien-deramond force-pushed the main-jd-opengraph-images branch from d9a53d2 to 6125877 Compare October 28, 2023 13:08
@julien-deramond julien-deramond changed the title feat: Open Graph images feat: generate Open Graph images and add og: and twitter: metadata Oct 28, 2023
@julien-deramond julien-deramond marked this pull request as ready for review October 28, 2023 13:09
@julien-deramond julien-deramond merged commit c1cf9e2 into main Oct 28, 2023
@julien-deramond julien-deramond deleted the main-jd-opengraph-images branch October 28, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Something can be improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant