Skip to content

Commit

Permalink
feat: support props to route blocks
Browse files Browse the repository at this point in the history
Close #49
  • Loading branch information
posva committed Aug 16, 2022
1 parent 45a8a59 commit 073c29c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions playground/src/pages/[...path].vue
Expand Up @@ -4,3 +4,9 @@
<p>{{ $route.params.path }} does not exist.</p>
</main>
</template>

<route>
{
"props": true
}
</route>
19 changes: 17 additions & 2 deletions src/codegen/generateRouteRecords.ts
Expand Up @@ -17,17 +17,32 @@ ${node
// TODO: should meta be defined a different way to allow preserving imports?
// const meta = node.value.overrides.meta

// path
return `${startIndent}{
${indentStr}path: '${node.path}',
${indentStr}${
node.value.filePaths.size ? `name: '${node.name}',` : '/* no name */'
}
${indentStr}${
${
// component
indentStr
}${
node.value.filePaths.size
? generateRouteRecordComponent(node, indentStr)
: '/* no component */'
}
${indentStr}${
${
// props
indentStr
}${
node.value.overrides.props != null
? `props: ${node.value.overrides.props},`
: '/* no props */'
}
${
// children
indentStr
}${
node.children.size > 0
? `children: [
${node
Expand Down

0 comments on commit 073c29c

Please sign in to comment.