Skip to content

Commit

Permalink
feat: add og
Browse files Browse the repository at this point in the history
  • Loading branch information
KagamiChan committed Oct 3, 2024
1 parent 16cdae6 commit cc268ef
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config = {
ignoreBuildErrors: true,
},
experimental: {
testProxy: true,
testProxy: process.env.NODE_ENV === 'test',
},
trailingSlash: true,
webpack: (config) => {
Expand Down
3 changes: 3 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { devices } from '@playwright/test'
import { defineConfig } from 'next/experimental/testmode/playwright.js'

// @ts-expect-error - NODE_ENV is set for the test environment
process.env.NODE_ENV = 'test'

/**
* See https://playwright.dev/docs/test-configuration.
*/
Expand Down
42 changes: 42 additions & 0 deletions src/app/[locale]/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable @next/next/no-img-element */
import { ImageResponse } from 'next/og'

const size = {
width: 1200,
height: 630,
}

export const runtime = 'edge'

const Image = async () => {
const logoSrc = await fetch(
new URL('../../assets/poi.png', import.meta.url),
).then((res) => res.arrayBuffer())

return new ImageResponse(
(
<div
style={{
fontSize: '240px',
fontWeight: '600',
lineHeight: '1.2em',
background: 'white',
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<img src={logoSrc as unknown as string} height="400" />
<div>poi</div>
</div>
),
{
...size,
},
)
}

export default Image
5 changes: 5 additions & 0 deletions src/app/[locale]/twitter-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Image from './opengraph-image'

export const runtime = 'edge'

export default Image

0 comments on commit cc268ef

Please sign in to comment.