mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 03:25:24 +00:00
implement session/preload on server
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
<script>
|
||||
import { setContext } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import { CONTEXT_KEY } from './internal';
|
||||
|
||||
export let Root;
|
||||
export let props;
|
||||
export let session;
|
||||
|
||||
setContext(CONTEXT_KEY, writable(session));
|
||||
setContext(CONTEXT_KEY, session);
|
||||
</script>
|
||||
|
||||
<Root {...props}/>
|
||||
@@ -1,3 +1,4 @@
|
||||
import { writable } from 'svelte/store.mjs';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import cookie from 'cookie';
|
||||
@@ -162,7 +163,7 @@ export function get_page_handler(
|
||||
path: req.path,
|
||||
query: req.query,
|
||||
params
|
||||
})
|
||||
}, session)
|
||||
: {};
|
||||
}))
|
||||
}
|
||||
@@ -231,7 +232,7 @@ export function get_page_handler(
|
||||
const { html, head, css } = App.render({
|
||||
Root: manifest.root,
|
||||
props: props,
|
||||
session
|
||||
session: writable(session)
|
||||
});
|
||||
|
||||
const serialized = {
|
||||
|
||||
Reference in New Issue
Block a user