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 {
|
export default function gemtext(config: GemtextConfig = {}): AstroIntegration {
|
||||||
if (!config.layout) {
|
|
||||||
config.layout = "/src/layouts/Layout.astro"
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
name: "astro-gemtext",
|
name: "astro-gemtext",
|
||||||
hooks: {
|
hooks: {
|
||||||
|
|||||||
+3
-9
@@ -14,11 +14,7 @@ import {
|
|||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
} from "astro/runtime/server/index.js";
|
} from "astro/runtime/server/index.js";
|
||||||
import { Fragment, jsx as h } from "astro/jsx-runtime";
|
import { Fragment, jsx as h } from "astro/jsx-runtime";
|
||||||
let Layout = undefined;
|
${config.layout ? `import Layout from ${JSON.stringify(config.layout)};` : ""}
|
||||||
try {
|
|
||||||
Layout = import(${JSON.stringify(config.layout)});
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
export const name = "TypstComponent";
|
export const name = "TypstComponent";
|
||||||
export const html = ${JSON.stringify(html)};
|
export const html = ${JSON.stringify(html)};
|
||||||
export const frontmatter = undefined;
|
export const frontmatter = undefined;
|
||||||
@@ -32,10 +28,8 @@ export function getHeadings() {
|
|||||||
}
|
}
|
||||||
export async function Content() {
|
export async function Content() {
|
||||||
const content = h(Fragment, {"set:html": html});
|
const content = h(Fragment, {"set:html": html});
|
||||||
if (Layout)
|
${config.layout && `return h(Layout, {title: url, children: content});`}
|
||||||
return h(Layout, {title: url, children: content});
|
${!config.layout && `return content;`}
|
||||||
else
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
export default Content;
|
export default Content;
|
||||||
`
|
`
|
||||||
|
|||||||
Reference in New Issue
Block a user