Use the right logic for generating RouteParams in elm-pages add.

This commit is contained in:
Dillon Kearns 2021-05-18 06:52:23 -07:00
parent 62f1ac56f8
commit 246a9d8a06

View File

@ -142,7 +142,22 @@ function routeVariantDefinition(name) {
* @param {string[]} name
*/
function paramsRecord(name) {
return `{ ${routeParams(name).map((param) => `${param} : String`)} }`;
return `{ ${parseRouteParams(name).map((param) => {
switch (param.kind) {
case "dynamic": {
return `${param.name} : String`;
}
case "optional": {
return `${param.name} : Maybe String`;
}
case "required-splat": {
return `splat : ( String , List String )`;
}
case "optional-splat": {
return `splat : List String`;
}
}
})} }`;
}
/**