@@ -34,19 +34,31 @@ async function fetchStats(username: string) {
3434 return { dead, struggling, alive, total : dead + struggling + alive }
3535}
3636
37- function buildSvg ( username : string , dead : number , struggling : number , alive : number , total : number ) {
37+ function buildSvg (
38+ username : string ,
39+ dead : number ,
40+ struggling : number ,
41+ alive : number ,
42+ total : number ,
43+ framed : boolean
44+ ) {
3845 const BAR_X = 16 , BAR_W = 408 , BAR_Y = 76 , BAR_H = 6
3946 const deadW = total === 0 ? 0 : Math . round ( ( dead / total ) * BAR_W )
4047 const strugglingW = total === 0 ? 0 : Math . round ( ( struggling / total ) * BAR_W )
4148 const aliveW = total === 0 ? BAR_W : BAR_W - deadW - strugglingW
4249 const MONO = "'Courier New','Courier',ui-monospace,monospace"
4350
51+ const outerBg = framed ? `<rect width="440" height="96" fill="#FAF6EF"/>` : ''
52+ const outerStroke = framed
53+ ? `<rect x="1" y="1" width="438" height="94" fill="none" stroke="#1a1a1a" stroke-width="2"/>`
54+ : ''
55+
4456 return `<svg width="440" height="96" viewBox="0 0 440 96" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Graveyard report for @${ username } ">
4557 <defs>
4658 <clipPath id="bar-clip"><rect x="${ BAR_X } " y="${ BAR_Y } " width="${ BAR_W } " height="${ BAR_H } "/></clipPath>
4759 </defs>
48- <rect width="440" height="96" fill="#FAF6EF"/>
49- <rect x="1" y="1" width="438" height="94" fill="none" stroke="#1a1a1a" stroke-width="2"/>
60+ ${ outerBg }
61+ ${ outerStroke }
5062
5163 <text x="16" y="28" font-family=${ JSON . stringify ( MONO ) } font-size="9" font-weight="700" fill="#9a9288" letter-spacing="2.2">GITHUB REPO GRAVEYARD</text>
5264
@@ -69,10 +81,13 @@ export async function GET(req: NextRequest) {
6981 return new NextResponse ( 'invalid username' , { status : 400 } )
7082 }
7183
84+ const framedParam = req . nextUrl . searchParams . get ( 'frame' )
85+ const framed = framedParam == null ? true : framedParam !== '0'
86+
7287 const stats = await fetchStats ( username )
7388 const { dead, struggling, alive, total } = stats ?? { dead : 0 , struggling : 0 , alive : 0 , total : 0 }
7489
75- const svg = buildSvg ( username , dead , struggling , alive , total )
90+ const svg = buildSvg ( username , dead , struggling , alive , total , framed )
7691
7792 return new NextResponse ( svg , {
7893 headers : {
0 commit comments