-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ability to use manual script injection in hooks (#89)
Co-authored-by: Hunter Johnston <[email protected]> Co-authored-by: Hunter Johnston <[email protected]>
- Loading branch information
1 parent
7f6fa59
commit 271a593
Showing
8 changed files
with
82 additions
and
25 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"mode-watcher": minor | ||
--- | ||
|
||
feat: add ability to disable head script injection via the `disableHeadScriptInjection` prop for handling in hooks.server files |
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,23 @@ | ||
<script lang="ts"> | ||
import { setInitialMode } from "./mode.js"; | ||
import type { ThemeColors } from "./types.js"; | ||
export let trueNonce: string = ""; | ||
export let initConfig: Parameters<typeof setInitialMode>[0]; | ||
export let themeColors: ThemeColors = undefined; | ||
</script> | ||
|
||
<svelte:head> | ||
{#if themeColors} | ||
<!-- default to dark mode for to allow testing --> | ||
<!-- this will be overwritten by FOUC prevention snippet below --> | ||
<!-- but that snippet does not run in vitest --> | ||
<meta name="theme-color" content={themeColors.dark} /> | ||
{/if} | ||
<!-- eslint-disable-next-line svelte/no-at-html-tags, prefer-template --> | ||
{@html `<script${trueNonce ? ` nonce=${trueNonce}` : ""}>(` + | ||
setInitialMode.toString() + | ||
`)(` + | ||
JSON.stringify(initConfig) + | ||
`);</script>`} | ||
</svelte:head> |
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 @@ | ||
<script lang="ts"> | ||
import type { ThemeColors } from "./types.js"; | ||
export let themeColors: ThemeColors = undefined; | ||
</script> | ||
|
||
{#if themeColors} | ||
<!-- default to dark mode for to allow testing --> | ||
<!-- this will be overwritten by FOUC prevention snippet below --> | ||
<!-- but that snippet does not run in vitest --> | ||
<meta name="theme-color" content={themeColors.dark} /> | ||
{/if} |
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
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