fix: bump version to 0.3.3 and fix filename title format

This commit is contained in:
aspizu
2025-03-10 04:32:06 +05:30
parent 0af6c14c51
commit 64e9046ccb
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "astro-gemtext", "name": "astro-gemtext",
"homepage": "https://github.com/aspizu/astro-gemtext", "homepage": "https://github.com/aspizu/astro-gemtext",
"version": "0.3.2", "version": "0.3.3",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
+4 -3
View File
@@ -1,4 +1,5 @@
import {HTMLRenderer, parse} from "gemtext" import {HTMLRenderer, parse} from "gemtext"
import path from "path"
import {pathToFileURL} from "url" import {pathToFileURL} from "url"
import type {Plugin} from "vite" import type {Plugin} from "vite"
import {ext, type GemtextConfig} from "./index.js" import {ext, type GemtextConfig} from "./index.js"
@@ -15,7 +16,7 @@ function transform(code: string, id: string, config: GemtextConfig) {
} }
} }
} else if (config.titleFormat === "filename") { } else if (config.titleFormat === "filename") {
title = pathToFileURL(id).pathname.split("/").pop() title = path.basename(id)
} }
const html = result.generate(HTMLRenderer) const html = result.generate(HTMLRenderer)
return ` return `
@@ -40,8 +41,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});
${config.layout && `return h(Layout, {title: ${JSON.stringify(title)}}, content);`} ${config.layout ? `return h(Layout, {title: ${JSON.stringify(title)}, children: content});` : ""}
${!config.layout && `return content;`} ${!config.layout ? `return content;` : ""}
} }
export default Content; export default Content;
` `