diff options
Diffstat (limited to 'src/vitePlugin.ts')
| -rw-r--r-- | src/vitePlugin.ts | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/vitePlugin.ts b/src/vitePlugin.ts index 48673a8..853c3b8 100644 --- a/src/vitePlugin.ts +++ b/src/vitePlugin.ts @@ -14,11 +14,7 @@ import { unescapeHTML, } from "astro/runtime/server/index.js"; import { Fragment, jsx as h } from "astro/jsx-runtime"; -let Layout = undefined; -try { - Layout = import(${JSON.stringify(config.layout)}); -} catch (e) { -} +${config.layout ? `import Layout from ${JSON.stringify(config.layout)};` : ""} export const name = "TypstComponent"; export const html = ${JSON.stringify(html)}; export const frontmatter = undefined; @@ -32,10 +28,8 @@ export function getHeadings() { } export async function Content() { const content = h(Fragment, {"set:html": html}); - if (Layout) - return h(Layout, {title: url, children: content}); - else - return content; + ${config.layout && `return h(Layout, {title: url, children: content});`} + ${!config.layout && `return content;`} } export default Content; ` |
