File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ const FONT_MAP: Record<string, string> = {
1515} ;
1616
1717// helpers
18+ function truncateUsername ( name : string , max = 20 ) : string {
19+ return name . length > max ? name . slice ( 0 , max ) + '…' : name ;
20+ }
21+
1822function getSizeScale ( size ?: 'small' | 'medium' | 'large' ) : number {
1923 if ( size === 'small' ) return 400 / SVG_WIDTH ;
2024 if ( size === 'large' ) return 800 / SVG_WIDTH ;
@@ -198,7 +202,7 @@ function renderFooter(
198202 const s = createScaler ( sf ) ;
199203 return `
200204 ${ ! params . hide_stats ? renderStatsSection ( stats , labels , s ) : '' }
201- ${ ! params . hide_title ? `<text x="${ s ( 300 ) } " y="${ s ( 50 ) } " text-anchor="middle" class="title">${ safeUser . toUpperCase ( ) } </text>` : '' }
205+ ${ ! params . hide_title ? `<text x="${ s ( 300 ) } " y="${ s ( 50 ) } " text-anchor="middle" class="title">${ truncateUsername ( safeUser ) . toUpperCase ( ) } </text>` : '' }
202206 <rect x="${ s ( 100 ) } " y="${ s ( 60 ) } " width="${ s ( 400 ) } " height="${ sf } " fill="${ accent } " fill-opacity="0.3">
203207 <animate attributeName="y" values="${ s ( 80 ) } ;${ s ( 320 ) } ;${ s ( 80 ) } " dur="${ params . speed || '8s' } " repeatCount="indefinite" />
204208 </rect>` ;
@@ -377,7 +381,7 @@ function generateAutoThemeSVG(
377381 ${ ! params . hide_stats ? renderStatsSection ( stats , labels , s ) : '' }
378382${
379383 ! params . hide_title
380- ? `<text x="${ s ( 300 ) } " y="${ s ( 50 ) } " text-anchor="middle" class="title">${ safeUser . toUpperCase ( ) } </text>`
384+ ? `<text x="${ s ( 300 ) } " y="${ s ( 50 ) } " text-anchor="middle" class="title">${ truncateUsername ( safeUser ) . toUpperCase ( ) } </text>`
381385 : ''
382386}
383387
You can’t perform that action at this time.
0 commit comments