remove cruft: just a content entry type now!

This commit is contained in:
2026-03-21 22:20:38 +00:00
parent 237990619e
commit 1248542cc6
4 changed files with 6 additions and 166 deletions
+5 -24
View File
@@ -1,19 +1,8 @@
import type {AstroIntegration, ContentEntryType, HookParameters} from "astro"
import {fileURLToPath} from "url"
import gemtextVitePlugin from "./vitePlugin.js"
import {parse as parseYaml} from "yaml"
/** Gemtext configuration options */
export interface GemtextConfig {
/** Absolute import path to the layout to use for all gemtext pages.
* If not provided, HMR and the Astro toolbar will not work. (default: none) */
layout?: string
/** The format to use for the page title. Can be one of:
* - `first-heading`: The first heading in the document will be used as the title. (default)
* - `filename`: The filename of the document will be used as the title.
*/
titleFormat?: "first-heading" | "filename"
}
export interface GemtextConfig {}
type SetupHookParams = HookParameters<"astro:config:setup"> & {
// `addPageExtension` and `contentEntryType` are not a public APIs
@@ -23,9 +12,6 @@ type SetupHookParams = HookParameters<"astro:config:setup"> & {
}
export default function gemtext(config: GemtextConfig = {}): AstroIntegration {
if (!config.titleFormat) {
config.titleFormat = "first-heading"
}
return {
name: "astro-gemtext",
hooks: {
@@ -35,10 +21,10 @@ export default function gemtext(config: GemtextConfig = {}): AstroIntegration {
params.addContentEntryType({
extensions: [".gmi"],
getRenderFunction: async (config) => {
return async (entry) => ({
html: entry.body ?? '',
frontmatter: entry.data,
});
return async (entry) => ({
html: entry.body ?? "",
frontmatter: entry.data,
})
},
getEntryInfo: async ({fileUrl, contents}) => {
const lines = contents.split("\n")
@@ -81,11 +67,6 @@ export default function gemtext(config: GemtextConfig = {}): AstroIntegration {
}
},
})
params.updateConfig({
vite: {
plugins: [gemtextVitePlugin(config)],
},
})
},
},
}