mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-11 19:04:30 +00:00
expose host in preload and page store
This commit is contained in:
@@ -121,7 +121,7 @@ export function select_target(url: URL): Target {
|
||||
const part = route.parts[route.parts.length - 1];
|
||||
const params = part.params ? part.params(match) : {};
|
||||
|
||||
const page = { path, query, params };
|
||||
const page = { host: location.host, path, query, params };
|
||||
|
||||
return { href: url.href, route, match, page };
|
||||
}
|
||||
@@ -129,7 +129,7 @@ export function select_target(url: URL): Target {
|
||||
}
|
||||
|
||||
export function handle_error(url: URL) {
|
||||
const { pathname, search } = location;
|
||||
const { host, pathname, search } = location;
|
||||
const { session, preloaded, status, error } = initial_data;
|
||||
|
||||
if (!root_preloaded) {
|
||||
@@ -154,7 +154,7 @@ export function handle_error(url: URL) {
|
||||
|
||||
}
|
||||
const query = extract_query(search);
|
||||
render(null, [], props, { path: pathname, query, params: {} });
|
||||
render(null, [], props, { host, path: pathname, query, params: {} });
|
||||
}
|
||||
|
||||
export function scroll_state() {
|
||||
@@ -301,6 +301,7 @@ export async function hydrate_target(target: Target): Promise<{
|
||||
|
||||
if (!root_preloaded) {
|
||||
root_preloaded = initial_data.preloaded[0] || root_preload.call(preload_context, {
|
||||
host: page.host,
|
||||
path: page.path,
|
||||
query: page.query,
|
||||
params: {}
|
||||
@@ -338,6 +339,7 @@ export async function hydrate_target(target: Target): Promise<{
|
||||
if (ready || !initial_data.preloaded[i + 1]) {
|
||||
preloaded = preload
|
||||
? await preload.call(preload_context, {
|
||||
host: page.host,
|
||||
path: page.path,
|
||||
query: page.query,
|
||||
params: part.params ? part.params(target.match) : {}
|
||||
|
||||
@@ -56,6 +56,7 @@ export type Redirect = {
|
||||
};
|
||||
|
||||
export type Page = {
|
||||
host: string;
|
||||
path: string;
|
||||
params: Record<string, string>;
|
||||
query: Record<string, string | string[]>;
|
||||
|
||||
@@ -149,6 +149,7 @@ export function get_page_handler(
|
||||
try {
|
||||
const root_preloaded = manifest.root_preload
|
||||
? manifest.root_preload.call(preload_context, {
|
||||
host: req.headers.host,
|
||||
path: req.path,
|
||||
query: req.query,
|
||||
params: {}
|
||||
@@ -168,6 +169,7 @@ export function get_page_handler(
|
||||
|
||||
return part.preload
|
||||
? part.preload.call(preload_context, {
|
||||
host: req.headers.host,
|
||||
path: req.path,
|
||||
query: req.query,
|
||||
params
|
||||
@@ -218,6 +220,7 @@ export function get_page_handler(
|
||||
stores: {
|
||||
page: {
|
||||
subscribe: writable({
|
||||
host: req.headers.host,
|
||||
path: req.path,
|
||||
query: req.query,
|
||||
params
|
||||
|
||||
Reference in New Issue
Block a user