Skip to content

Commit

Permalink
chore: unite css & content before replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
yhdgms1 committed Jun 15, 2022
1 parent bbd4509 commit 6ac2574
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ export const buildSvgDataURI: BuildSvgDataURI = async (node, options) => {

const base64Resources = await useFetcher(uniqueResources, options.fetcher)

content = `<style>${css}</style>${content}`

for (const [url, base64] of base64Resources) {
css = css.replaceAll(url, base64)
content = content.replaceAll(url, base64)
}
}

const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}'><foreignObject x='0' y='0' width='${width}' height='${height}'><style>${css}</style>${content}</foreignObject></svg>`
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}'><foreignObject x='0' y='0' width='${width}' height='${height}'>${content}</foreignObject></svg>`

const dataURI = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`

Expand Down

0 comments on commit 6ac2574

Please sign in to comment.