Skip to content

Commit

Permalink
feat: 静的生成でogpを生成する手法に切り替え
Browse files Browse the repository at this point in the history
  • Loading branch information
吉野敬太郎 authored and 吉野敬太郎 committed Sep 18, 2024
1 parent 2619030 commit 52f811a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Binary file modified bun.lockb
Binary file not shown.
7 changes: 5 additions & 2 deletions src/pages/og/[...slug].png.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { APIContext, APIRoute } from "astro";
import { getEntry } from "astro:content";
import { getCollection, getEntry } from "astro:content";
import { getOgImage } from "./_getOgImage";

export const prerender = false;
export const getStaticPaths = async () => {
const posts = await getCollection("post");
return posts.map((post) => ({ params: { slug: post.slug } }));
};

export async function GET({ params, redirect }: APIContext) {
const { slug } = params;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/og/_getOgImage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import satori from "satori";
import { OgImage } from "./_OgImage";
const sharp = require("sharp");
// import sharp from "sharp";
import sharp from "sharp";

export async function getOgImage(text: string): Promise<Buffer> {
const notoSansJpUrl = `https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@600`;
Expand Down

0 comments on commit 52f811a

Please sign in to comment.