Commit 6985433
docs: add width/height to customer-logo SVGs to reduce CLS (#20839)
* docs: add width/height to customer-logo SVGs to reduce CLS
The customer-logo.html partial renders customer/case-study logo SVGs
without width/height attributes, so the browser cannot reserve layout
space for them before the stylesheet that ultimately sizes them
(object-contain inside a fixed-size wrapper) has been applied. The
homepage alone renders ~170 of these images.
Hugo's image-processing pipeline does not expose .Width/.Height for
SVG resources (confirmed: calling it throws "this method is only
available for raster images"), so this parses each SVG's own declared
viewBox (or, when absent, its root <svg> width/height attributes)
directly from the source markup and emits those as real width/height
attributes, rounded to the nearest integer since the HTML5 spec
requires non-negative integers there and several source files declare
fractional viewBox dimensions. When neither is present, the partial
falls back to the previous unsized behavior rather than fabricate a
number.
Verified in an isolated Hugo harness (real site's asset pipeline does
not build in this environment) against all 42 real SVGs in
static/logos/customers/: all 42 now render with valid integer
width/height attributes with no build errors.
* docs: accept single-quoted viewBox when parsing customer-logo SVGs
The viewBox regex required double quotes, so an SVG that writes its
attributes single-quoted fell through to the unsized path. Match either
quote character and strip the prefix/suffix positionally, since the two
TrimPrefix/TrimSuffix calls can no longer key off a fixed literal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: workprentice <257153108+workprentice@users.noreply.github.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 6a997af commit 6985433
1 file changed
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
94 | 135 | | |
95 | 136 | | |
96 | | - | |
| 137 | + | |
97 | 138 | | |
98 | 139 | | |
99 | 140 | | |
| |||
0 commit comments