skip layout components where none is provided - fixes #312

This commit is contained in:
Rich Harris
2018-07-23 16:31:00 -04:00
parent f8c731ca21
commit 731d4f535c
5 changed files with 56 additions and 36 deletions

View File

@@ -79,6 +79,8 @@ function generate_client(
pattern: ${page.pattern},
parts: [
${page.parts.map(part => {
if (part === null) return 'null';
if (part.params.length > 0) {
const props = part.params.map((param, i) => `${param}: match[${i + 1}]`);
return `{ component: ${part.component.name}, params: match => ({ ${props.join(', ')} }) }`;
@@ -150,6 +152,8 @@ function generate_server(
pattern: ${page.pattern},
parts: [
${page.parts.map(part => {
if (part === null) return 'null';
const props = [
`name: "${part.component.name}"`,
`component: ${part.component.name}`