From a64b617d4c9fe36d392ba649f2e59059b1cdb8a0 Mon Sep 17 00:00:00 2001 From: KRISHNPRIY2820 <138807694+KRISHNPRIY2820@users.noreply.github.com> Date: Sat, 15 Feb 2025 11:52:48 +0530 Subject: [PATCH] Enhance error handling and add checks for missing files or inconsistencies --- order.js | 29 +++++++++++++++++++++++++++++ svelte.config.js | 37 +++++++++++++++++++++++++++++++------ vite.config.js | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 order.js diff --git a/order.js b/order.js new file mode 100644 index 00000000..bd98cbd6 --- /dev/null +++ b/order.js @@ -0,0 +1,29 @@ +import fs from 'fs'; +import path from 'path'; + +const orderFilePath = path.join('src', 'routes', 'team', 'order.json'); +let orderData; + +try { + orderData = JSON.parse(fs.readFileSync(orderFilePath, 'utf-8')); +} catch (error) { + console.error(`Error reading order.json: ${error.message}`); + orderData = {}; // Handle as empty object or suitable default +} + +const mdFiles = fs.readdirSync(path.join('src', 'routes', 'team')).filter(file => file.endsWith('.md')); +const mdFileNames = mdFiles.map(file => file.replace('.md', '')); + +const orderEntries = Object.keys(orderData); + +orderEntries.forEach(entry => { + if (!mdFileNames.includes(entry)) { + console.error(`Error: Entry "${entry}" in order.json has no corresponding Markdown file.`); + } +}); + +mdFileNames.forEach(fileName => { + if (!orderEntries.includes(fileName)) { + console.error(`Error: Markdown file "${fileName}.md" is not listed in order.json.`); + } +}); diff --git a/svelte.config.js b/svelte.config.js index ed8daae5..ac883d7a 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,9 +1,33 @@ +// import preprocess from "svelte-preprocess"; +// import { mdsvex } from "mdsvex"; +// import { mdsvexConfig } from "./mdsvex.config.js"; +// import adapter from "@sveltejs/adapter-netlify"; +// import svg from '@poppanator/sveltekit-svg' + + +// /** @type {import('@sveltejs/kit').Config} */ +// const config = { +// extensions: [".svelte", ...mdsvexConfig.extensions], +// preprocess: [ +// preprocess({ +// postcss: true, +// }), +// mdsvex(mdsvexConfig), +// ], +// kit: { +// adapter: adapter(), +// // hydrate the
element in src/app.html +// // vite: { +// // plugins: [svg()] +// // }, +// }, +// }; +// // import preprocess from "svelte-preprocess"; import { mdsvex } from "mdsvex"; import { mdsvexConfig } from "./mdsvex.config.js"; import adapter from "@sveltejs/adapter-netlify"; -import svg from '@poppanator/sveltekit-svg' - +import svg from '@poppanator/sveltekit-svg'; /** @type {import('@sveltejs/kit').Config} */ const config = { @@ -17,10 +41,11 @@ const config = { kit: { adapter: adapter(), // hydrate the
element in src/app.html - // vite: { - // plugins: [svg()] - // }, - }, + vite: { + plugins: [svg()] + } + } }; export default config; + diff --git a/vite.config.js b/vite.config.js index f7d2c265..9647ea34 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,34 @@ +// import { sveltekit } from '@sveltejs/kit/vite'; +// /** @type {import('vite').UserConfig} */ +// const config = { +// plugins: [sveltekit()] +// }; +// export default config; + + import { sveltekit } from '@sveltejs/kit/vite'; +import mdsvex from 'mdsvex'; + /** @type {import('vite').UserConfig} */ const config = { - plugins: [sveltekit()] + plugins: [sveltekit()], + extensions: ['.svelte', '.svx'], + preprocess: [ + mdsvex({ + // MDsveX options + onwarn: (warning, handler) => { + // Print warning details + console.warn(warning); + + // Print offending file + if (warning.loc && warning.loc.file) { + console.warn(`Error in file: ${warning.loc.file}`); + } + + handler(warning); + } + }) + ] }; -export default config; \ No newline at end of file + +export default config;