summaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authoraspizu <aspizu@protonmail.com>2025-03-10 02:58:09 +0530
committeraspizu <aspizu@protonmail.com>2025-03-10 02:58:09 +0530
commit8137b02b1ea25836f80e6d61fae7592ddb6837f2 (patch)
tree41c14a3a75bec0dc2a83c6de36b56f88aa1b4404 /src/index.ts
initial commit
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts41
1 files changed, 41 insertions, 0 deletions
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()],
+ },
+ })
+ },
+ },
+ }
+}