From 8137b02b1ea25836f80e6d61fae7592ddb6837f2 Mon Sep 17 00:00:00 2001 From: aspizu Date: Mon, 10 Mar 2025 02:58:09 +0530 Subject: initial commit --- src/index.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/index.ts (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..27ed46a --- /dev/null +++ b/src/index.ts @@ -0,0 +1,41 @@ +import type {AstroIntegration, ContentEntryType, HookParameters} from "astro" +import {fileURLToPath} from "url" +import gemtextVitePlugin from "./vitePlugin.js" + +export const ext = "gmi" + +type SetupHookParams = HookParameters<"astro:config:setup"> & { + // `addPageExtension` and `contentEntryType` are not a public APIs + // Add type defs here + addPageExtension: (extension: string) => void + addContentEntryType: (contentEntryType: ContentEntryType) => void +} + +export default function gemtext(): AstroIntegration { + return { + name: "astro-gemtext", + hooks: { + "astro:config:setup": async (_params) => { + const params = _params as SetupHookParams + params.addRenderer({ + name: "astro-gemtext", + serverEntrypoint: fileURLToPath( + new URL("./renderer.js", import.meta.url), + ), + }) + params.addPageExtension(ext) + params.addContentEntryType({ + extensions: [`.${ext}`], + getEntryInfo: async (params) => { + throw new Error("Not implemented") + }, + }) + params.updateConfig({ + vite: { + plugins: [gemtextVitePlugin()], + }, + }) + }, + }, + } +} -- cgit v1.2.3