Accept other formats in embed function

This commit is contained in:
lowlighter committed 2021-05-01 18:38:38 +02:00
1 parent b2871d9946
commit 00a6e9aa4d
2 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -122,8 +122,8 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
console.debug(`metrics/compute/${login} > embed called with`)
console.debug(q)
//Compute rendering
const {rendered} = await metrics({login, q}, {...arguments[1], convert:null}, arguments[2])
return `<img class="metrics-cachable" data-name="${name}" src="data:image/svg+xml;base64,${Buffer.from(rendered).toString("base64")}">`
const {rendered} = await metrics({login, q}, {...arguments[1], convert:["svg", "png", "jpeg"].includes(q["config.output"]) ? q["config.output"] : null}, arguments[2])
return `<img class="metrics-cachable" data-name="${name}" src="data:image/${{png:"png", jpeg:"jpeg"}[q["config.output"]] ?? "svg+xml"};base64,${Buffer.from(rendered).toString("base64")}">`
}
//Rendering template source
let rendered = source.replace(/\{\{ (?<content>[\s\S]*?) \}\}/g, "{%= $<content> %}")