-
Notifications
You must be signed in to change notification settings - Fork 16
fix(seo): restore the homepage OpenGraph image #12593
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
Open
jd
wants to merge
1
commit into
main
from
devs/jd/agentic-readiness/restore-homepage-opengraph-image--fb9a23ea
+35
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
| import { getOgImageUrl } from './getOgImageUrl'; | ||
|
|
||
| // `getOgImageUrl` looks a derived filename up in the set of images | ||
| // astro-og-canvas actually generated, which comes from the content collection | ||
| // and so needs the Astro build pipeline. Stub that set and test the derivation | ||
| // — the half where the homepage bug was. | ||
| vi.mock('../pages/open-graph/[...path]', () => ({ | ||
| getStaticPaths: async () => [ | ||
| { params: { path: 'index.png' } }, | ||
| { params: { path: 'merge-queue.png' } }, | ||
| ], | ||
| })); | ||
|
|
||
| describe('getOgImageUrl', () => { | ||
| it('resolves the homepage to the index image', () => { | ||
| // Regression: stripping the slashes off `/` left an empty slug, so the | ||
| // homepage was the one page that shipped an empty `og:image`. | ||
| expect(getOgImageUrl('/')).toBe('/open-graph/index.png'); | ||
| }); | ||
|
|
||
| it('resolves a normal page, with or without a trailing slash', () => { | ||
| expect(getOgImageUrl('/merge-queue')).toBe('/open-graph/merge-queue.png'); | ||
| expect(getOgImageUrl('/merge-queue/')).toBe('/open-graph/merge-queue.png'); | ||
| }); | ||
|
|
||
| it('returns undefined when no image was generated', () => { | ||
| expect(getOgImageUrl('/not-a-page')).toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.