diff --git a/src/components/DynamicSolution.tsx b/src/components/DynamicSolution.tsx index 129dc30..81ea169 100644 --- a/src/components/DynamicSolution.tsx +++ b/src/components/DynamicSolution.tsx @@ -1,14 +1,14 @@ -import { lazy, Suspense } from "react"; - // this component allows us to dynamically import components for question results that are unique to each specific question. + +// https://vite.dev/guide/features.html#glob-import +let x: Record = import.meta.glob('./solutions/*', { eager: true, import: "default" }) export function DynamicSolution({ resultComponent }: { resultComponent: string }) { - // btw...be aware of footguns when engaging in jank - // See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats - const Component = lazy(() => import(/* @vite-ignore */`./solutions/${resultComponent}`)); + let path = `./solutions/${resultComponent}.tsx` + let Component = x[path] + + if (!Component) return null return ( - Loading...}> - - - ); + + ) }; diff --git a/src/layouts/Day.astro b/src/layouts/Day.astro index 2f83f08..ee34933 100644 --- a/src/layouts/Day.astro +++ b/src/layouts/Day.astro @@ -58,10 +58,6 @@ const { day, title, resultComponent } = Astro.props;
- { - resultComponent && ( - - ) - } + {resultComponent && }