From 4e2aea8a5a414b3bcfac0168bea4f6afd032e8f5 Mon Sep 17 00:00:00 2001
From: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 26 Aug 2024 21:12:45 +0000
Subject: [PATCH] chore(deps): bump @napi-rs/simple-git from 0.1.17 to 0.1.19 (#1376)

---
 quartz/plugins/index.ts |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/quartz/plugins/index.ts b/quartz/plugins/index.ts
index 23440fb..df9fd1d 100644
--- a/quartz/plugins/index.ts
+++ b/quartz/plugins/index.ts
@@ -1,6 +1,6 @@
-import { StaticResources } from "../resources"
-import { FilePath, ServerSlug } from "../path"
-import { BuildCtx } from "../ctx"
+import { StaticResources } from "../util/resources"
+import { FilePath, FullSlug } from "../util/path"
+import { BuildCtx } from "../util/ctx"
 
 export function getStaticResourcesFromPlugins(ctx: BuildCtx) {
   const staticResources: StaticResources = {
@@ -18,6 +18,23 @@
     }
   }
 
+  // if serving locally, listen for rebuilds and reload the page
+  if (ctx.argv.serve) {
+    const wsUrl = ctx.argv.remoteDevHost
+      ? `wss://${ctx.argv.remoteDevHost}:${ctx.argv.wsPort}`
+      : `ws://localhost:${ctx.argv.wsPort}`
+
+    staticResources.js.push({
+      loadTime: "afterDOMReady",
+      contentType: "inline",
+      script: `
+        const socket = new WebSocket('${wsUrl}')
+        // reload(true) ensures resources like images and scripts are fetched again in firefox
+        socket.addEventListener('message', () => document.location.reload(true))
+      `,
+    })
+  }
+
   return staticResources
 }
 
@@ -28,7 +45,8 @@
 declare module "vfile" {
   // inserted in processors.ts
   interface DataMap {
-    slug: ServerSlug
+    slug: FullSlug
     filePath: FilePath
+    relativePath: FilePath
   }
 }

--
Gitblit v1.10.0