| 208 | } |
| 209 | |
| 210 | const serializeAttrs = (attrs: CheerioElement['attribs']) => { |
| 211 | const attrStr = Object.keys(attrs || {}) |
| 212 | .map((name) => { |
| 213 | const reactName = htmlToReactAttributes[name] || name |
| 214 | const value = attrs[name] |
| 215 | |
| 216 | // allow process.env access to work dynamically still |
| 217 | if (value.match(/%([a-zA-Z0-9_]{0,})%/)) { |
| 218 | return `${reactName}={\`${value.replace( |
| 219 | /%([a-zA-Z0-9_]{0,})%/g, |
| 220 | (subStr) => { |
| 221 | return `\${process.env.${subStr.slice(1, -1)}}` |
| 222 | } |
| 223 | )}\`}` |
| 224 | } |
| 225 | return `${reactName}="${value}"` |
| 226 | }) |
| 227 | .join(' ') |
| 228 | |
| 229 | return attrStr.length > 0 ? ` ${attrStr}` : '' |
| 230 | } |
| 231 | const serializedHeadTags: string[] = [] |
| 232 | const serializedBodyTags: string[] = [] |
| 233 | |