mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: update auto-gen OG images to allow special char usage in title
Update the implementation of og image generation code to allow special character usage in title. fix #103, fix #88
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import generateOgImages from "@utils/generateOgImages";
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
export const GET: APIRoute = async () => new Response(await generateOgImages());
|
||||
|
||||
export const getStaticPaths = () => [
|
||||
{ params: { ogImage: "generating images with " } },
|
||||
];
|
||||
@@ -1,17 +0,0 @@
|
||||
import { getCollection } from "astro:content";
|
||||
import generateOgImage from "@utils/generateOgImage";
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
export const GET: APIRoute = async ({ params }) =>
|
||||
new Response(await generateOgImage(params.ogTitle));
|
||||
|
||||
const postImportResult = await getCollection("blog", ({ data }) => !data.draft);
|
||||
const posts = Object.values(postImportResult);
|
||||
|
||||
export function getStaticPaths() {
|
||||
return posts
|
||||
.filter(({ data }) => !data.ogImage)
|
||||
.map(({ data }) => ({
|
||||
params: { ogTitle: data.title },
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user