Skip to content

Commit 20022d0

Browse files
authored
[feat] add App.PageData type (#6226)
Closes #5951
1 parent c779034 commit 20022d0

File tree

61 files changed

+922
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+922
-198
lines changed

.changeset/loud-peaches-enjoy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'create-svelte': patch
3+
'@sveltejs/kit': patch
4+
---
5+
6+
[feat] add App.PageData type

packages/create-svelte/templates/default/src/app.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ declare namespace App {
66
userid: string;
77
}
88

9+
// interface PageData {}
10+
911
// interface Platform {}
1012

1113
// interface PrivateEnv {}

packages/create-svelte/templates/libskeleton/src/app.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// and what to do when importing types
66
declare namespace App {
77
// interface Locals {}
8+
// interface PageData {}
89
// interface Platform {}
910
// interface PrivateEnv {}
1011
// interface PublicEnv {}

packages/create-svelte/templates/skeleton/src/app.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// and what to do when importing types
44
declare namespace App {
55
// interface Locals {}
6+
// interface PageData {}
67
// interface Platform {}
78
// interface PrivateEnv {}
89
// interface PublicEnv {}

packages/kit/src/core/sync/create_manifest_data/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function create_routes_and_nodes(cwd, config, fallback) {
180180
component: project_relative
181181
};
182182
} else if (item.is_layout) {
183-
if (!route.layout) route.layout = { depth };
183+
if (!route.layout) route.layout = { depth, child_pages: [] };
184184
route.layout.component = project_relative;
185185
if (item.uses_layout !== undefined) route.layout.parent_id = item.uses_layout;
186186
} else {
@@ -189,7 +189,7 @@ function create_routes_and_nodes(cwd, config, fallback) {
189189
if (item.uses_layout !== undefined) route.leaf.parent_id = item.uses_layout;
190190
}
191191
} else if (item.is_layout) {
192-
if (!route.layout) route.layout = { depth };
192+
if (!route.layout) route.layout = { depth, child_pages: [] };
193193
route.layout[item.kind] = project_relative;
194194
} else if (item.is_page) {
195195
if (!route.leaf) route.leaf = { depth };
@@ -223,7 +223,7 @@ function create_routes_and_nodes(cwd, config, fallback) {
223223
}
224224

225225
if (!root.layout?.component) {
226-
if (!root.layout) root.layout = { depth: 0 };
226+
if (!root.layout) root.layout = { depth: 0, child_pages: [] };
227227
root.layout.component = posixify(path.relative(cwd, `${fallback}/layout.svelte`));
228228
}
229229

@@ -290,6 +290,9 @@ function create_routes_and_nodes(cwd, config, fallback) {
290290
}
291291

292292
if (current_route.layout) {
293+
/** @type {import('types').PageNode[]} */ (current_route.layout.child_pages).push(
294+
route.leaf
295+
);
293296
current_node.parent = current_node = current_route.layout;
294297
parent_id = current_node.parent_id;
295298
} else {

packages/kit/src/core/sync/sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { write_client_manifest } from './write_client_manifest.js';
44
import { write_matchers } from './write_matchers.js';
55
import { write_root } from './write_root.js';
66
import { write_tsconfig } from './write_tsconfig.js';
7-
import { write_types, write_all_types } from './write_types.js';
7+
import { write_types, write_all_types } from './write_types/index.js';
88
import { write_ambient } from './write_ambient.js';
99

1010
/**

packages/kit/src/core/sync/write_types.spec.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)