@prismicio/svelte 3.0.0-pr.70.0fcf71f → 3.0.0-pr.71.61897e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
const { repositoryName, routePrefix = "preview", routePrefixName = routePrefix }: Props = $props()
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// `v=5` opts into the toolbar's modern flow.
|
|
27
|
+
// TODO: Remove `&v=5` once `getToolbarSrc()` from `@prismicio/client` adds it.
|
|
28
|
+
const toolbarSrc = $derived(`${getToolbarSrc(repositoryName)}&v=5`)
|
|
27
29
|
|
|
28
30
|
/** Set to `true` when the next `beforeNavigate()` call should not prefix the route. */
|
|
29
31
|
let endingPreview = $state(false)
|
|
@@ -34,6 +34,14 @@ export const redirectToPreviewURL = async (config) => {
|
|
|
34
34
|
httpOnly: false,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
// The toolbar's `v=5` flow follows the preview session with this cookie.
|
|
38
|
+
const session = new URL(config.request.url).searchParams.get("session");
|
|
39
|
+
if (session) {
|
|
40
|
+
config.cookies.set("io.prismic.previewSession", session, {
|
|
41
|
+
path: "/",
|
|
42
|
+
httpOnly: false,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
37
45
|
return new Response(undefined, {
|
|
38
46
|
status: 307,
|
|
39
47
|
headers: {
|
package/package.json
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
const { repositoryName, routePrefix = "preview", routePrefixName = routePrefix }: Props = $props()
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// `v=5` opts into the toolbar's modern flow.
|
|
27
|
+
// TODO: Remove `&v=5` once `getToolbarSrc()` from `@prismicio/client` adds it.
|
|
28
|
+
const toolbarSrc = $derived(`${getToolbarSrc(repositoryName)}&v=5`)
|
|
27
29
|
|
|
28
30
|
/** Set to `true` when the next `beforeNavigate()` call should not prefix the route. */
|
|
29
31
|
let endingPreview = $state(false)
|
|
@@ -69,6 +69,15 @@ export const redirectToPreviewURL = async (
|
|
|
69
69
|
})
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// The toolbar's `v=5` flow follows the preview session with this cookie.
|
|
73
|
+
const session = new URL(config.request.url).searchParams.get("session")
|
|
74
|
+
if (session) {
|
|
75
|
+
config.cookies.set("io.prismic.previewSession", session, {
|
|
76
|
+
path: "/",
|
|
77
|
+
httpOnly: false,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
72
81
|
return new Response(undefined, {
|
|
73
82
|
status: 307,
|
|
74
83
|
headers: {
|