File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
app/[locale]/next-data/og Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -17,16 +17,20 @@ export const GET = async (request: Request) => {
1717 const hasTitle = searchParams . has ( 'title' ) ;
1818 const title = hasTitle ? searchParams . get ( 'title' ) ?. slice ( 0 , 100 ) : undefined ;
1919
20- //?type=<type>
21- const type = searchParams . get ( 'type' ) ?? 'announcement' ;
20+ //?type=<type> - if undefined default to announcement
21+ const typeParam = searchParams . get ( 'type' ) ?? 'announcement' ;
2222
2323 const typeAttributes : { [ key : string ] : string } = {
2424 announcement : tailwindConfig . theme . colors . green [ '700' ] ,
2525 release : tailwindConfig . theme . colors . info [ '600' ] ,
2626 vulnerability : tailwindConfig . theme . colors . warning [ '600' ] ,
2727 } ;
2828
29- const gridBackground = `radial-gradient(circle, ${ hexToRGBA ( typeAttributes [ type ] ) } , transparent)` ;
29+ // use the mapped value, or if not found use announcement
30+ const type =
31+ typeAttributes [ typeParam ] ?? tailwindConfig . theme . colors . green [ '700' ] ;
32+
33+ const gridBackground = `radial-gradient(circle, ${ hexToRGBA ( type ) } , transparent)` ;
3034
3135 return new ImageResponse (
3236 (
Original file line number Diff line number Diff line change 1- export const hexToRGBA = ( hex : string , alpha = 0.9 ) => {
1+ export const hexToRGBA = ( hex : string = '' , alpha = 0.9 ) => {
22 hex = hex . replace ( / ^ # / , '' ) ;
33
44 const bigint = parseInt ( hex , 16 ) ;
You can’t perform that action at this time.
0 commit comments