From 7b5c8c9cd3256bf1041024176bba6b748a4638da Mon Sep 17 00:00:00 2001 From: nea Date: Mon, 21 Nov 2022 18:46:09 +0100 Subject: UserPlugins: Add clickable badges to external user plugins This patch adds a button to each user plugin (this is determined by the plugin directory). Additionally user plugins can specify an `externalLink` in their plugin definition to have their badge be clickable and link to an external website. Co-Authored-By: exhq <91651232+exhq@users.noreply.github.com> --- scripts/build/common.mjs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'scripts/build/common.mjs') diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index 11aaa81..35af0f4 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -60,19 +60,23 @@ export const globPlugins = { }); build.onLoad({ filter, namespace: "import-plugins" }, async () => { - const pluginDirs = ["plugins", "userplugins"]; + const pluginDirs = [ + { dir: "plugins", official: true }, + { dir: "userplugins", official: false }, + ]; let code = ""; let plugins = "\n"; let i = 0; - for (const dir of pluginDirs) { - if (!existsSync(`./src/${dir}`)) continue; - const files = await readdir(`./src/${dir}`); - for (const file of files) { + for (const pluginDirectory of pluginDirs) { + const pluginPath = `./src/${pluginDirectory.dir}`; + if (!existsSync(pluginPath)) continue; + for (const file of await readdir(pluginPath)) { if (file === "index.ts") { continue; } const mod = `p${i}`; - code += `import ${mod} from "./${dir}/${file.replace(/.tsx?$/, "")}";\n`; + code += `import ${mod} from "./${pluginDirectory.dir}/${file.replace(/.tsx?$/, "")}";\n`; + code += `${mod}['isUserPlugin'] = ${!pluginDirectory.official};`; plugins += `[${mod}.name]:${mod},\n`; i++; } -- cgit