diff options
| author | aspizu <aspizu@protonmail.com> | 2025-03-10 04:32:06 +0530 |
|---|---|---|
| committer | aspizu <aspizu@protonmail.com> | 2025-03-10 04:32:06 +0530 |
| commit | 64e9046ccb5fa4a54772714bf7326be205c0f487 (patch) | |
| tree | c9d98ecb814575b68d8aeb881cdc9b593f5146f0 /src/vitePlugin.ts | |
| parent | 0af6c14c51d49ee97d6dfc28d93135c65a61e3d3 (diff) | |
fix: bump version to 0.3.3 and fix filename title format
Diffstat (limited to 'src/vitePlugin.ts')
| -rw-r--r-- | src/vitePlugin.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/vitePlugin.ts b/src/vitePlugin.ts index 138f8c8..1568b14 100644 --- a/src/vitePlugin.ts +++ b/src/vitePlugin.ts @@ -1,4 +1,5 @@ import {HTMLRenderer, parse} from "gemtext" +import path from "path" import {pathToFileURL} from "url" import type {Plugin} from "vite" import {ext, type GemtextConfig} from "./index.js" @@ -15,7 +16,7 @@ function transform(code: string, id: string, config: GemtextConfig) { } } } else if (config.titleFormat === "filename") { - title = pathToFileURL(id).pathname.split("/").pop() + title = path.basename(id) } const html = result.generate(HTMLRenderer) return ` @@ -40,8 +41,8 @@ export function getHeadings() { } export async function Content() { const content = h(Fragment, {"set:html": html}); - ${config.layout && `return h(Layout, {title: ${JSON.stringify(title)}}, content);`} - ${!config.layout && `return content;`} + ${config.layout ? `return h(Layout, {title: ${JSON.stringify(title)}, children: content});` : ""} + ${!config.layout ? `return content;` : ""} } export default Content; ` |
