-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
1 parent
0f82206
commit a83c871
Showing
2 changed files
with
27 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,7 @@ | ||
import type { APIRoute } from "astro"; | ||
import { generateOgImageForSite } from "@utils/generateOgImages"; | ||
|
||
export const GET: APIRoute = async () => | ||
new Response(await generateOgImageForSite(), { | ||
headers: { "Content-Type": "image/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,20 @@ | ||
import type { APIRoute } from "astro"; | ||
import { getCollection, type CollectionEntry } from "astro:content"; | ||
import { generateOgImageForPost } from "@utils/generateOgImages"; | ||
import { slugifyStr } from "@utils/slugify"; | ||
|
||
export async function getStaticPaths() { | ||
const posts = await getCollection("blog").then(p => | ||
p.filter(({ data }) => !data.draft && !data.ogImage) | ||
); | ||
|
||
return posts.map(post => ({ | ||
params: { slug: slugifyStr(post.data.title) }, | ||
props: post, | ||
})); | ||
} | ||
|
||
export const GET: APIRoute = async ({ props }) => | ||
new Response(await generateOgImageForPost(props as CollectionEntry<"blog">), { | ||
headers: { "Content-Type": "image/png" }, | ||
}); |