From a07eddb5f10d6a45a31c03c42857331bad43b5ac Mon Sep 17 00:00:00 2001 From: Pablo Pirata Date: Sat, 10 Aug 2024 15:35:45 +0200 Subject: [PATCH] update importTemplate --- src/pages/Resume.jsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pages/Resume.jsx b/src/pages/Resume.jsx index c0ba0c9..d49c339 100644 --- a/src/pages/Resume.jsx +++ b/src/pages/Resume.jsx @@ -40,12 +40,17 @@ const useStyles = makeStyles((theme) => ({ }, })); -const importTemplate = (template) => - lazy(() => - import(`../components/ResumeTemplates/${template}/Index`).catch(() => - import('../components/ResumeTemplates/Default/Index') - ) - ); +const importTemplate = (template) => { + const templates = { + Default: import('../components/ResumeTemplates/Default/Index'), + // Compact: import('../components/ResumeTemplates/Compact/Index'), + // VanHack: import('../components/ResumeTemplates/VanHack/Index'), + }; + + return lazy(() => { + return templates[template]; + }); +}; const parseMarkdown = (obj) => { if (typeof obj !== 'object' || obj === null) { @@ -93,6 +98,7 @@ const ResumePage = () => { useEffect(() => { async function loadTemplate() { const Template = await importTemplate(resumeTemplateName); + console.log('the template', resumeTemplateName, Template); const jsonResume = { ...baseResume, ...convertToRegularObject(cloneDeep(toggleableJsonResume)),