-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(optimization): hydrate toaster component on demand
Closes #16
- Loading branch information
1 parent
1a79b5a
commit 82bcdf7
Showing
9 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
Submodule cloudflare
updated
from 58f2de to 30fd22
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { ClientDirective } from "astro"; | ||
|
||
export default (function (load, options) { | ||
window.addEventListener( | ||
options.value, | ||
async () => { | ||
const hydrate = await load(); | ||
await hydrate(); | ||
}, | ||
{ once: true }, | ||
); | ||
} satisfies ClientDirective); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import "astro"; | ||
|
||
declare module "astro" { | ||
interface AstroClientDirectives { | ||
"client:event"?: string; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { AstroIntegration } from "astro"; | ||
|
||
export default (): AstroIntegration => ({ | ||
name: "client:event", | ||
hooks: { | ||
"astro:config:setup": ({ addClientDirective }) => { | ||
addClientDirective({ | ||
name: "event", | ||
entrypoint: "./lib/event-directive.ts", | ||
}); | ||
}, | ||
}, | ||
}); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const CLIENT_EVENT_TOASTER = "toaster-hydrate"; | ||
|
||
interface Config { | ||
status: string | false; | ||
} | ||
|
This file contains 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
This file contains 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