Update default config.padding and use metadata.inputs instead of query values in core

This commit is contained in:
lowlighter
2021-02-09 22:00:07 +01:00
parent 9673ea713a
commit 5523e66fb8
6 changed files with 17 additions and 18 deletions

View File

@@ -124,14 +124,14 @@
}
/**Render svg */
export async function svgresize(svg, {paddings = ["6%"], convert} = {}) {
export async function svgresize(svg, {paddings, convert}) {
//Instantiate browser if needed
if (!svgresize.browser) {
svgresize.browser = await puppeteer.launch({headless:true, executablePath:process.env.PUPPETEER_BROWSER_PATH, args:["--no-sandbox", "--disable-extensions", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]})
console.debug(`metrics/svgresize > started ${await svgresize.browser.version()}`)
}
//Format padding
const [pw = 1, ph] = paddings.map(padding => `${padding}`.substring(0, padding.length-1)).map(value => 1+Number(value)/100)
const [pw = 1, ph] = (Array.isArray(paddings) ? paddings : `${paddings}`.split(",").map(x => x.trim())).map(padding => `${padding}`.substring(0, padding.length-1)).map(value => 1+Number(value)/100)
const padding = {width:pw, height:ph ?? pw}
console.debug(`metrics/svgresize > padding width*${padding.width}, height*${padding.height}`)
//Render through browser and resize height