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

[Feature] CldOgImage Component #23

Closed
colbyfayock opened this issue Sep 20, 2024 · 4 comments · Fixed by #60
Closed

[Feature] CldOgImage Component #23

colbyfayock opened this issue Sep 20, 2024 · 4 comments · Fixed by #60
Labels
enhancement New feature or request help wanted Extra attention is needed released

Comments

@colbyfayock
Copy link
Collaborator

Feature Request

Is your feature request related to a problem? Please describe.

Create a new CldOgImage component that allows for easy drop-in support for social cards

Describe the solution you'd like

The goal is to mostly replicate the CldOgImage component from Next Cloudinary: https://next.cloudinary.dev/cldogimage/basic-usage

Given Astro doesn't have a similar concept of a Head component out of the box like the Next.js Pages Router does, we can simply return a series of meta tags that will allow someone to easily drop in a Social Cards.

At its basics, the component should work as follows:

---
import { CldOgImage } from 'astro-cloudinary';
---
<CldOgImage
  src="<Public ID>"
/>

CldOgImage would be using the getCldOgImageUrl under the hood exposing all of the same APIs, which would allow for transformations.

https://github.com/cloudinary-community/next-cloudinary/blob/main/next-cloudinary/src/components/CldOgImage/CldOgImage.tsx

The meta tags that should be added are, at a minimum:

<meta property="og:image" content={ogImageUrl} />
<meta property="og:image:secure_url" content={ogImageUrl} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content={alt} />
<meta property="twitter:title" content={title} />
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:image" content={ogImageUrl} />

Twitter Title here is particularly interesting as the social card will not work without a Twitter Title, is there a way we can infer this from Astor without a user manually specifying this? Should we throw a warning if the prop is not defined?

@colbyfayock colbyfayock added enhancement New feature or request help wanted Extra attention is needed labels Sep 20, 2024
@taciturnaxolotl
Copy link
Contributor

i'll take a look and see if i can implement that today

@taciturnaxolotl
Copy link
Contributor

is there a prettier or biome style config you would like me to follow?

@taciturnaxolotl
Copy link
Contributor

made a pr! lmk if you want it to be implemented differently

Copy link

github-actions bot commented Nov 1, 2024

🎉 This issue has been resolved in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants