Pelayo Arbués
2023-08-31 2d6dc176c3e1fbb520a5da1beb60bbb1d8e948ba
quartz/plugins/emitters/componentResources.ts
@@ -103,16 +103,22 @@
  } else {
    componentResources.afterDOMLoaded.push(`
        window.spaNavigate = (url, _) => window.location.assign(url)
        const event = new CustomEvent("nav", { detail: { slug: document.body.dataset.slug } })
        const event = new CustomEvent("nav", { detail: { url: document.body.dataset.slug } })
        document.dispatchEvent(event)`)
  }
  let wsUrl = `ws://localhost:${ctx.argv.wsPort}`
  if (ctx.argv.remoteDevHost) {
    wsUrl = `wss://${ctx.argv.remoteDevHost}:${ctx.argv.wsPort}`
  }
  if (reloadScript) {
    staticResources.js.push({
      loadTime: "afterDOMReady",
      contentType: "inline",
      script: `
          const socket = new WebSocket('ws://localhost:3001')
          const socket = new WebSocket('${wsUrl}')
          socket.addEventListener('message', () => document.location.reload())
        `,
    })