logic works, need to unhardcode values tho

This commit is contained in:
Ryan Haskell-Glatz 2019-12-23 20:33:12 -06:00
parent 5d08a96b8d
commit 1802c2e1b1
2 changed files with 19 additions and 9 deletions

View File

@ -730,8 +730,12 @@ pagesToBundle item =
-- ROUTES
routes : List Filepath -> String
routes filepaths =
routes :
{ paths : List Filepath
, pathsWithFiles : List Filepath
}
-> String
routes { paths, pathsWithFiles } =
"""
module Generated.Routes exposing
( Route
@ -774,16 +778,16 @@ parsers : List (Parser (Route -> a) a)
parsers =
{{routesParserLines}}
"""
|> String.replace "{{routesFolderImports}}" (routesFolderImports filepaths)
|> String.replace "{{routesTypeAliases}}" (routesTypeAliases filepaths)
|> String.replace "{{routesRecords}}" (routesRecords filepaths)
|> String.replace "{{routesParserLines}}" (routesParserLines filepaths)
|> String.replace "{{routesFolderImports}}" (routesFolderImports paths)
|> String.replace "{{routesTypeAliases}}" (routesTypeAliases pathsWithFiles)
|> String.replace "{{routesRecords}}" (routesRecords pathsWithFiles)
|> String.replace "{{routesParserLines}}" (routesParserLines pathsWithFiles)
|> String.trim
routesFolderImports : List Filepath -> String
routesFolderImports files =
files
routesFolderImports paths =
paths
|> List.map dropLast
|> Set.fromList
|> Set.toList

View File

@ -95,7 +95,13 @@ handle flags =
build : BuildConfig -> Cmd msg
build { paths } =
List.concat
[ [ File [ "Routes" ] (File.routes paths) ]
[ [ File [ "Routes" ]
(File.routes
{ paths = paths ++ [ [ "Authors", "Dynamic" ], [ "Authors", "Dynamic", "Posts" ] ]
, pathsWithFiles = paths
}
)
]
, paths
|> List.foldl groupByFolder Dict.empty
|> Debug.log "grouped"