Fix embed function in action

This commit is contained in:
lowlighter
2021-04-26 20:07:29 +02:00
parent 1f7b6b4c96
commit 07f957ef5e
3 changed files with 11 additions and 8 deletions

View File

@@ -83,9 +83,10 @@
console.debug(error)
}
//Embed method
const embed = async(q, name = Math.random().toString().substring(2)) => {
const embed = async(name, q) => {
q = Object.fromEntries([...Object.entries(q).map(([key, value]) => [key.replace(/^plugin_/, "").replace(/_/g, "."), value]), ["base", false], ["config.animations", false]])
const {rendered} = await metrics({login, q}, {...arguments[1], convert:null}, arguments[2])
const plugins = Object.fromEntries(Object.entries(arguments[1].plugins).map(([key, value]) => [key, {...value, enabled:true}]))
const {rendered} = await metrics({login, q}, {...arguments[1], plugins, convert:null}, arguments[2])
return `<img class="metrics-cachable" data-name="${name}" src="data:image/svg+xml;base64,${Buffer.from(rendered).toString("base64")}">`
}
//Rendering template source