feat: remove default layout assignment in gemtext function and update layout import logic
This commit is contained in:
@@ -16,9 +16,6 @@ type SetupHookParams = HookParameters<"astro:config:setup"> & {
|
||||
}
|
||||
|
||||
export default function gemtext(config: GemtextConfig = {}): AstroIntegration {
|
||||
if (!config.layout) {
|
||||
config.layout = "/src/layouts/Layout.astro"
|
||||
}
|
||||
return {
|
||||
name: "astro-gemtext",
|
||||
hooks: {
|
||||
|
||||
+3
-9
@@ -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;
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user