-
-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix twitter preview image & add readme
- Loading branch information
Showing
7 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,10 @@ | ||
Images stored here must follow the naming convention `<post-slug>.webp` and must always be .webp files, e.g. `2023-11-21-coverlettergpt.webp`. | ||
|
||
This is because OG Image URLs are automatically generated for each blog post based on the logic in `src/components/HeadWithOGImage.astro`: | ||
|
||
```tsx | ||
const ogImageUrl = new URL( | ||
`/og-images/${Astro.props.id.replace(/blog\//, '').replace(/\.\w+$/, '.webp')}`, | ||
Astro.site, | ||
) | ||
``` |
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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,10 @@ | ||
Images stored here must follow the naming convention `<post-slug>.webp` and must always be .webp files, e.g. `2023-11-21-coverlettergpt.webp`. | ||
|
||
This is because OG Image URLs are automatically generated for each blog post based on the logic in `src/components/HeadWithOGImage.astro`: | ||
|
||
```tsx | ||
const ogImageUrl = new URL( | ||
`/og-images/${Astro.props.id.replace(/blog\//, '').replace(/\.\w+$/, '.webp')}`, | ||
Astro.site, | ||
) | ||
``` |
This file contains 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,19 @@ | ||
--- | ||
import type { Props } from '@astrojs/starlight/props' | ||
import Default from '@astrojs/starlight/components/Head.astro' | ||
// Get the URL of the generated image for the current page using its | ||
// ID and replace the file extension with `.png`. | ||
const ogImageUrl = new URL( | ||
`/og-images/${Astro.props.id.replace(/blog\//, '').replace(/\.\w+$/, '.webp')}`, | ||
Astro.site, | ||
) | ||
--- | ||
|
||
<Default {...Astro.props}><slot /></Default> | ||
|
||
<!-- Open Graph images. --> | ||
<meta property="og:image" content={ogImageUrl} /> | ||
<meta property="og:image:width" content="1200" /> | ||
<meta property="og:image:height" content="630" /> | ||
<meta name="twitter:image" content={ogImageUrl} /> |
This file contains 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