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: Dynamic og image #1344 #1616

Open
wants to merge 100 commits into
base: v2
Choose a base branch
from

Conversation

vasfvitor
Copy link
Contributor

@vasfvitor vasfvitor commented Oct 14, 2023

Continuing from #1608

OUTDATED:
Still working on it. But thinking whether we should consider https://github.com/delucis/astro-og-canvas or another implementation. Current PR is based on: https://github.com/JonasKruckenberg/JonasKruckenberg/blob/main/src/pages/social-image/[...path].png.ts

Files:
astro.config.mjs - Added Head component override; Updated Footer override reference; removed head meta tags

templates.ts - receives the frontmatter data to build SVG that will be processed by Sharp. Currently it's all done inline.

utils.ts - helper functions

[...path].png.ts - Astro dynamic routes mixed with social-image generation via Sharp. It has to be in /pages

Reference:
https://docs.astro.build/en/core-concepts/endpoints/#static-file-endpoints
https://docs.astro.build/en/core-concepts/routing/#dynamic-routes

tsconfig.json - import alias to /assets where the .ts files are

Issue:
Locally the font (SF-Pro) is working, but still need to check how live/preview build will behave. Sharp can't process embedded fonts in SVG. So the current implementation has SVG importing a font file. But Sharp apparently needs the font to be installed in the system (by default, SF-Pro will not be on netlify and possible any other font will), so maybe we'll need fonts.conf file.

Revert "Update [...path].png.ts"

This reverts commit 9d7329d.
break down logic in dyanmic [...]png, utils., templates.

added path to /blog

Templates based on figma design exported svg
this is needed because /blog don't have a corresponding .md or mdx file
added ts config reference to assets
Revert "Update [...path].png.ts"

This reverts commit 9d7329d.
break down logic in dyanmic [...]png, utils., templates.

added path to /blog

Templates based on figma design exported svg
this is needed because /blog don't have a corresponding .md or mdx file
added ts config reference to assets
head social image with better social image logic
@netlify
Copy link

netlify bot commented Oct 14, 2023

Deploy Preview for tauri-v2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 050fa32
🔍 Latest deploy log https://app.netlify.com/sites/tauri-v2/deploys/669291acf290f00008a1f6fc
😎 Deploy Preview https://deploy-preview-1616--tauri-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@vasfvitor
Copy link
Contributor Author

vasfvitor commented Oct 14, 2023

PR deploy time: 2m 46s

Current deploy time: 1m 52s

54s increase in deploy time

image

@vasfvitor
Copy link
Contributor Author

vasfvitor commented Oct 14, 2023

[update in the next comment]

Original design:

Local preview:

Netlify preview:

Three Two issues:
(1) The font and (2) date are wrong on Netlify preview. (3) Text's left side margin does not match original design. Plus the grid isn't in the same position. It seems that the svg shifter left.

(3) fixed
(2) there wasn't a problem after all, the post actual date is 2023-05-03 and live/preview is ok. Only locally is different, no problem :D
(1) fixed

I need input if I could continue to work on this.

Thanks

@simonhyll simonhyll added this to the Version 2.0 milestone Feb 26, 2024
@simonhyll simonhyll requested a review from a team February 29, 2024 00:59
@simonhyll simonhyll added the enhancement Does it add or improve content? label May 23, 2024

// https://github.com/withastro/docs/blob/main/src/pages/0/0.ts
// https://www.github.com/withastro/docs/pull/4266/commits/030073f32d6dfe586c6e1da8d48d6b5485541ba2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can't find an issue, can we open one to point to so we know when this hack may be replaced by an improved implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasfvitor
Copy link
Contributor Author

vasfvitor commented Jul 12, 2024

I'll revisit this soon because the head override will have to include the recent head changes someway, or find a way to inject the og metatags into the head without overriding it. This was expected and at the time I gave a shot at it but failed

well... it can be as simple as just copying the contents tho... not sure... I'll look again

@tweidinger
Copy link
Contributor

is this needed for our 2.0 release or are we okay to have this later on @vasfvitor ?

@vasfvitor vasfvitor removed this from the Version 2.0 milestone Sep 3, 2024
@vasfvitor
Copy link
Contributor Author

is this needed for our 2.0 release or are we okay to have this later on @vasfvitor ?

no need I'd say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Does it add or improve content?
Projects
Status: 📋 In review
Development

Successfully merging this pull request may close these issues.

5 participants