Last active
November 22, 2023 06:03
-
-
Save miguelrk/c9f37e311a42addf04fa91a7b704af5e to your computer and use it in GitHub Desktop.
A Deno Fresh plugin for Preact Signals `bind:value` inspired by https://gist.github.com/marvinhagemeister/daada86f82466dff81d48840c8d5f27b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { setup } from "./shared.ts"; | |
export default function hydrate() { | |
setup(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Plugin } from "$fresh/server.ts"; | |
import { setup } from "./shared.ts"; | |
export const bindSignal = (): Plugin<unknown> => { | |
setup(); | |
const url = new URL("./main.ts", import.meta.url).href; | |
const main = `data:application/javascript,import hydrate from "${url}"; | |
export default function(state) { hydrate(); } | |
`; | |
return { | |
name: "bindSignal", | |
entrypoints: { main }, | |
async renderAsync(ctx) { | |
await ctx.renderAsync(); | |
return { | |
scripts: [{ entrypoint: "main", state: [] }], | |
}; | |
}, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment