Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 28, 2023

Conversation

julien-deramond
Copy link
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

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 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
3 checks passed
@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