From 00a6e9aa4da8e305c62e471b16bf7ab66e2bad28 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Sat, 1 May 2021 18:38:38 +0200 Subject: [PATCH] Accept other formats in embed function --- source/app/action/index.mjs | 6 +++--- source/app/metrics/index.mjs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index bfc07a0c..917e3c34 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -315,11 +315,11 @@ async function wait(seconds) { //Cache if (/markdown/.test(convert)) { - const regex = /(?)/g + const regex = /(?)/g let matched = null while (matched = regex.exec(rendered)?.groups) { //eslint-disable-line no-cond-assign - const {match, name, content} = matched - let path = `${_markdown_cache}/${name}.svg` + const {match, name, format, content} = matched + let path = `${_markdown_cache}/${name}.${format.replace(/[+].*$/g, "")}` console.debug(`Processing ${path}`) let sha = null try { diff --git a/source/app/metrics/index.mjs b/source/app/metrics/index.mjs index 63fbd0d4..0466b1f9 100644 --- a/source/app/metrics/index.mjs +++ b/source/app/metrics/index.mjs @@ -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 `` + const {rendered} = await metrics({login, q}, {...arguments[1], convert:["svg", "png", "jpeg"].includes(q["config.output"]) ? q["config.output"] : null}, arguments[2]) + return `` } //Rendering template source let rendered = source.replace(/\{\{ (?[\s\S]*?) \}\}/g, "{%= $ %}")