1+ import { readFileSync } from 'fs' ;
2+ import { join } from 'path' ;
13import ObjectData from '@/../public/resources_wikidata.json' ;
24
3- export const runtime = 'edge' ;
5+ // We remove 'edge' runtime to allow Node.js 'fs' access during the 'next build'
6+ // static generation phase for the 'output: export' configuration.
7+ export const runtime = 'nodejs' ;
48
59// Optionally statically generate standard badges
610export async function generateStaticParams ( ) {
7- return ObjectData . map ( ( resource ) => ( { slug : resource . slug } ) ) ;
11+ return ObjectData . map ( ( resource ) => ( { slug : resource . id } ) ) ;
812}
913
1014export async function GET ( request , { params } ) {
@@ -15,6 +19,17 @@ export async function GET(request, { params }) {
1519 return new Response ( 'Not Found' , { status : 404 } ) ;
1620 }
1721
22+ // Read official logo content from public directory
23+ let logoSvgContent = '' ;
24+ try {
25+ const logoPath = join ( process . cwd ( ) , 'public/logo-tm.svg' ) ;
26+ logoSvgContent = readFileSync ( logoPath , 'utf8' ) ;
27+ // Clean up the SVG for nesting: remove XML declaration and doctype
28+ logoSvgContent = logoSvgContent . replace ( / < \? x m l .* \? > / g, '' ) . replace ( / < ! D O C T Y P E .* ?> / g, '' ) ;
29+ } catch ( error ) {
30+ console . error ( 'Failed to read logo-tm.svg:' , error ) ;
31+ }
32+
1833 // Calculate prestige completeness
1934 const isComplete = resource . yearLaunched != null &&
2035 resource . isActivelyRecruiting != null &&
@@ -25,12 +40,15 @@ export async function GET(request, { params }) {
2540 const rightText = isComplete ? "Complete Data Source" : "Verified Data Source" ;
2641
2742 // Approximate width calculation (standard fonts)
28- const leftWidth = 120 ;
43+ const logoWidth = 24 ;
44+ const leftTextWidth = 185 ; // Increased to fit "Yourself to Science™" comfortably
45+ const leftWidth = logoWidth + leftTextWidth ;
2946 const rightWidth = isComplete ? 135 : 130 ;
3047 const totalWidth = leftWidth + rightWidth ;
3148
3249 // Official Theme Colors
33- const colorLeft = "#1A1C1E" ; // m3-on-surface (black title color)
50+ const colorLeft = "#ffffff" ; // Header match (white)
51+ const textColor = "#202124" ; // google-text
3452 // Gold badge vs standard blue badge
3553 const colorRight = isComplete ? "#FDBB2D" : "#1156B0" ; // stroke-yellow-dark / google-blue
3654
@@ -40,6 +58,10 @@ export async function GET(request, { params }) {
4058 <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
4159 <stop offset="1" stop-opacity=".1"/>
4260 </linearGradient>
61+ <linearGradient id="g" x1="0%" y1="0%" x2="0%" y2="100%">
62+ <stop offset="0%" stop-color="#ffd92d"/>
63+ <stop offset="100%" stop-color="#B35F00"/>
64+ </linearGradient>
4365 <clipPath id="r">
4466 <rect width="${ totalWidth } " height="20" rx="3" fill="#fff"/>
4567 </clipPath>
@@ -48,11 +70,20 @@ export async function GET(request, { params }) {
4870 <rect x="${ leftWidth } " width="${ rightWidth } " height="20" fill="${ colorRight } "/>
4971 <rect width="${ totalWidth } " height="20" fill="url(#s)"/>
5072 </g>
51- <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
52- <text aria-hidden="true" x="${ leftWidth * 5 } " y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="${ ( leftWidth - 20 ) * 10 } ">${ leftText } </text>
53- <text x="${ leftWidth * 5 } " y="140" transform="scale(.1)" fill="#fff" textLength="${ ( leftWidth - 20 ) * 10 } ">${ leftText } </text>
54- <text aria-hidden="true" x="${ ( leftWidth + rightWidth / 2 ) * 10 } " y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="${ ( rightWidth - 20 ) * 10 } ">${ rightText } </text>
55- <text x="${ ( leftWidth + rightWidth / 2 ) * 10 } " y="140" transform="scale(.1)" fill="#fff" textLength="${ ( rightWidth - 20 ) * 10 } ">${ rightText } </text>
73+ <g font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
74+ <!-- Official 'Yourself to Science' Logo Integrated via File Read -->
75+ <g transform="translate(4, 2) scale(0.069)">
76+ ${ logoSvgContent }
77+ </g>
78+
79+ <g transform="scale(.1)">
80+ <text x="${ ( logoWidth + ( leftTextWidth / 2 ) ) * 10 } " y="140" fill="${ textColor } " text-anchor="middle">
81+ <tspan font-weight="500">Your</tspan><tspan fill="url(#g)" stroke="#ffd92d" stroke-width="3" font-weight="bold">self</tspan><tspan font-weight="500"> to Science</tspan>
82+ <tspan font-size="70" baseline-shift="super">™</tspan>
83+ </text>
84+ </g>
85+
86+ <text x="${ ( leftWidth + rightWidth / 2 ) * 10 } " y="140" transform="scale(.1)" fill="#fff" text-anchor="middle" textLength="${ ( rightWidth - 20 ) * 10 } ">${ rightText } </text>
5687 </g>
5788 </svg>` ;
5889
0 commit comments