diff --git a/source/app/metrics/metadata.mjs b/source/app/metrics/metadata.mjs index a41de43b..99e53094 100644 --- a/source/app/metrics/metadata.mjs +++ b/source/app/metrics/metadata.mjs @@ -382,6 +382,23 @@ metadata.template = async function({__templates, name, plugins, logger}) { } } + //Demo for main and individual readmes + function demo({colspan = null} = {}) { + return [ + ` `, + `${Object.entries(meta.examples ?? {}).map(([text, link]) => { + let img = `` + if (text !== "default") { + const open = text.charAt(0) === "+" ? " open" : "" + img = `
${open ? text.substring(1) : text}${img}
` + } + return ` ${img}` + }).join("\n")}`, + ` `, + ` ` + ].join("\n") + } + //Header table const header = [ "", @@ -409,17 +426,7 @@ metadata.template = async function({__templates, name, plugins, logger}) { ].filter(v => v).join(", ")}`, ` `, ` `, - ` `, + demo({colspan:2}), ` `, "
`, - `${Object.entries(meta.examples ?? {}).map(([text, link]) => { - let img = `` - if (text !== "default") { - const open = text.charAt(0) === "+" ? " open" : "" - img = `
${open ? text.substring(1) : text}${img}
` - } - return ` ${img}` - }).join("\n")}`, - ` `, - `
" ].join("\n") @@ -432,7 +439,7 @@ metadata.template = async function({__templates, name, plugins, logger}) { formats:meta.formats ?? null, supports:meta.supports ?? null, readme:{ - demo:readme.match(/(?[\s\S]*?<[/]table>)/)?.groups?.demo?.replace(/<[/]?(?:table|tr)>/g, "")?.trim() ?? (name === "community" ? '' : ""), + demo:demo(), compatibility:{ ...Object.fromEntries(Object.entries(compatibility).filter(([_, value]) => value)), ...Object.fromEntries(Object.entries(compatibility).filter(([_, value]) => !value).map(([key, value]) => [key, meta.formats?.includes("markdown") ? "embed" : value])),
See documentation 🌍