File tree 4 files changed +35
-8
lines changed 4 files changed +35
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { ImageResponse } from 'next/og'
2
2
import testData from '@/utils/data'
3
+ import { badgeSettings , badgeSize } from '@/utils/consts'
3
4
4
5
export const dynamic = 'force-static'
5
6
@@ -21,21 +22,20 @@ export async function GET(request) {
21
22
22
23
const badge = (
23
24
< Badge
24
- label = "Next.js runtime v5"
25
+ label = { badgeSettings . label }
25
26
labelStyle = { labelStyle }
26
27
value = { testData . nextVersion }
27
28
valueStyle = { valueStyle }
28
29
/>
29
30
)
30
31
return new ImageResponse ( badge , {
31
- width : 400 ,
32
- height : 60 ,
32
+ ...badgeSettings . imageSize ,
33
33
} )
34
34
}
35
35
36
36
function Badge ( { label, labelStyle, value, valueStyle } ) {
37
37
return (
38
- < div tw = "flex items-center w-full h-full text-[28px ] rounded-md overflow-hidden bg-transparent" >
38
+ < div tw = "flex items-center w-full h-full text-[26px ] rounded-md overflow-hidden bg-transparent" >
39
39
< span tw = "items-center h-full p-3.5" style = { labelStyle } >
40
40
{ label }
41
41
</ span >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import StatsRow from '@/components/stats'
6
6
import testData from '@/utils/data'
7
7
import { CopyIcon } from '@/components/icons'
8
8
import CopyBadgeButton from '@/components/copy-badge'
9
+ import { badgeSettings } from '@/utils/consts'
9
10
10
11
export default function Home ( ) {
11
12
// User can switch between two test suite tables: one with all non-empty suites,
@@ -41,7 +42,12 @@ function Header() {
41
42
</ span >
42
43
< span className = "hidden md:flex gap-2 items-center" >
43
44
< a href = "/" target = "_blank" >
44
- < img src = "/badge" width = "200" height = "30" alt = "Netlify Next.js runtime v5 test status" />
45
+ < img
46
+ src = "/badge"
47
+ width = { badgeSettings . displaySize . width }
48
+ height = { badgeSettings . displaySize . height }
49
+ alt = { badgeSettings . alt }
50
+ />
45
51
</ a >
46
52
< CopyBadgeButton />
47
53
</ span >
Original file line number Diff line number Diff line change 1
1
'use client'
2
+ import { useEffect , useState } from 'react'
2
3
import { CopyIcon } from './icons'
3
-
4
- const host = 'https://runtime-e2e-report.netlify.app' // fixed
5
- const badgeLink = `<a href="${ host } /" target="_blank"><img src="${ host } /badge" width="200" height="30" alt="Netlify Next.js runtime v5 test status" /></a>`
4
+ import { badgeDisplaySize , badgeSettings } from '@/utils/consts'
6
5
7
6
export default function CopyBadgeButton ( ) {
7
+ const [ host , setHost ] = useState ( '' )
8
+ useEffect ( ( ) => {
9
+ setHost ( window ?. location . origin || '' )
10
+ } , [ ] )
11
+
12
+ const badgeLink = `
13
+ <a href="${ host } /" target="_blank">
14
+ <img
15
+ src="${ host } /badge"
16
+ width="${ badgeSettings . displaySize . width } "
17
+ height="${ badgeSettings . displaySize . height } "
18
+ alt="${ badgeSettings . alt } "
19
+ />
20
+ </a>`
21
+
8
22
return (
9
23
< button
10
24
className = "btn btn-xs btn-outline text-white rounded px-0.5"
Original file line number Diff line number Diff line change
1
+ export const badgeSettings = {
2
+ // Badge image resolution should be 2x display size for hi-res displays
3
+ imageSize : { width : 370 , height : 50 } ,
4
+ displaySize : { width : 185 , height : 25 } ,
5
+ label : 'Next.js runtime v5' ,
6
+ alt : 'Netlify Next.js runtime v5 test status' ,
7
+ }
You can’t perform that action at this time.
0 commit comments