mirror of
https://github.com/ryannhg/elm-spa.git
synced 2024-11-22 01:32:43 +03:00
logic works, need to unhardcode values tho
This commit is contained in:
parent
5d08a96b8d
commit
1802c2e1b1
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user