From 895d1f3b52b1160a58a28c451266d44f767c54b1 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Mon, 6 Jun 2022 15:52:57 +0200 Subject: [PATCH] docs(themes): handle non-json themes --- website/export_themes.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/website/export_themes.js b/website/export_themes.js index 44ee4d4b..9dcd2a4b 100644 --- a/website/export_themes.js +++ b/website/export_themes.js @@ -18,6 +18,10 @@ function newThemeConfig(rpromptOffset = 40, cursorPadding = 30, author = "", bgC return config; } +function isValidTheme(theme) { + return theme.endsWith('.omp.json') || theme.endsWith('.omp.toml') || theme.endsWith('.omp.yaml') +} + let themeConfigOverrrides = new Map(); themeConfigOverrrides.set('agnoster.omp.json', newThemeConfig(40, 40)); themeConfigOverrrides.set('agnosterplus.omp.json', newThemeConfig(80)); @@ -62,7 +66,7 @@ themeConfigOverrrides.set('zash.omp.json', newThemeConfig(40, 40)); let links = new Array(); for (const theme of themes) { - if (!theme.endsWith('.omp.json')) { + if (!isValidTheme(theme)) { continue; } const configPath = path.join(themesConfigDir, theme); @@ -87,13 +91,12 @@ themeConfigOverrrides.set('zash.omp.json', newThemeConfig(40, 40)); continue; } - const image = theme.replace('.omp.json', '.png'); + const themeName = theme.slice(0, -9); + const image = themeName + '.png'; const toPath = path.join(themesStaticDir, image); await fs.promises.rename(image, toPath); - const themeName = theme.replace('.omp.json', ''); - const themeData = ` ### [${themeName}]