Skip to content

Commit

Permalink
feat: functionsの実験(続き)
Browse files Browse the repository at this point in the history
  • Loading branch information
吉野敬太郎 authored and 吉野敬太郎 committed Sep 16, 2024
1 parent 4671400 commit 4c98eac
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
Binary file modified bun.lockb
Binary file not shown.
11 changes: 11 additions & 0 deletions functions/greet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ImageResponse } from "@cloudflare/pages-plugin-vercel-og/api";

export const onRequest: PagesFunction = async () => {
return new ImageResponse(
<div style={{ display: "flex" }}>Hello, world!</div>,
{
width: 1200,
height: 630,
}
);
};
4 changes: 2 additions & 2 deletions functions/post/_middleware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const getFontData = async (url: string): Promise<ArrayBuffer> => {
return await fetch(resource[1]).then(async (res) => await res.arrayBuffer());
};

export const onRequest = vercelOGPagesPlugin<OgImageProps>({
export const onRequest: PagesFunction = vercelOGPagesPlugin<OgImageProps>({
imagePathSuffix: "/og-image.png",
component: ({ ogTitle }) => {
return <OgImage ogTitle={ogTitle} />;
Expand All @@ -110,7 +110,7 @@ export const onRequest = vercelOGPagesPlugin<OgImageProps>({
on: {
'meta[property="og:title"]': (props) => ({
element(element) {
props.ogTitle = element.getAttribute("content");
props.ogTitle = element.getAttribute("content") ?? "ゆっきーの砂場";
},
}),
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"typescript-eslint": "^7.2.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240909.0",
"@playwright/test": "^1.36.2",
"@tailwindcss/typography": "^0.5.9",
"@types/bun": "^1.0.8",
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "astro/tsconfigs/strict",
"include": ["**/*.ts", "**/*.tsx", "**/*.astro"],
"compilerOptions": {
"types": [
"bun-types"
],
"types": ["bun-types", "@cloudflare/workers-types/2023-07-01"],
"jsx": "react-jsx",
"jsxImportSource": "react"
}
}
}
4 changes: 4 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#:schema node_modules/wrangler/config-schema.json
name = "yukky-sandbox"
compatibility_date = "2024-09-02"
pages_build_output_dir = "./dist"

0 comments on commit 4c98eac

Please sign in to comment.