-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
98 additions
and
13 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,5 @@ | ||
--- | ||
'astro-og-canvas': minor | ||
--- | ||
|
||
Switches to using the “full” `canvaskit-wasm` build to generate images. This fixes support for rendering as JPEG or WEBP instead of the default PNG. |
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,11 @@ | ||
--- | ||
'astro-og-canvas': minor | ||
--- | ||
|
||
Updates `canvaskit-wasm` to the latest release | ||
|
||
**Note:** pnpm users may need to manually update in their project too: | ||
|
||
```sh | ||
pnpm i canvaskit-wasm@^0.39.1 | ||
``` |
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,31 @@ | ||
import { OGImageRoute } from 'astro-og-canvas'; | ||
|
||
export const { getStaticPaths, GET } = OGImageRoute({ | ||
param: 'path', | ||
pages: { | ||
'png.md': { | ||
title: 'Test image (PNG)', | ||
description: 'Renders an Open Graph image to a PNG file', | ||
format: 'PNG', | ||
}, | ||
'jpeg.md': { | ||
title: 'Test image (JPEG)', | ||
description: 'Renders an Open Graph image to a JPEG file', | ||
format: 'JPEG', | ||
}, | ||
'webp.md': { | ||
title: 'Test image (WEBP)', | ||
description: 'Renders an Open Graph image to a WEBP file', | ||
format: 'WEBP', | ||
}, | ||
}, | ||
getSlug(path, { format }) { | ||
const ext = format.toLowerCase(); | ||
path = path.replace(/^\/src\/pages\//, ''); | ||
path = path.replace(/\.[^.]*$/, '') + '.' + ext; | ||
return path; | ||
}, | ||
getImageOptions: (_path, page) => ({ | ||
...page, | ||
}), | ||
}); |
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,17 @@ | ||
--- | ||
title: Different formats | ||
description: Test page demonstrating that images render correctly in different formats | ||
layout: ../../layouts/Layout.astro | ||
--- | ||
|
||
# Astro OpenGraph Images with CanvasKit | ||
|
||
This test renders the same image to different formats. | ||
|
||
![Example PNG](/formats/png.png) | ||
|
||
![Example JPEG](/formats/jpeg.jpeg) | ||
|
||
![Example WEBP](/formats/webp.webp) | ||
|
||
- [Home](/) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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