mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 01:12:50 +03:00
Wire up baseUrl for Route module generation.
This commit is contained in:
parent
92365d95b1
commit
08015f49b9
@ -23,6 +23,7 @@ import Pretty
|
||||
|
||||
type alias Flags =
|
||||
{ templates : List (List String)
|
||||
, basePath : String
|
||||
}
|
||||
|
||||
|
||||
@ -30,9 +31,9 @@ main : Program Flags () ()
|
||||
main =
|
||||
Platform.worker
|
||||
{ init =
|
||||
\{ templates } ->
|
||||
\{ templates, basePath } ->
|
||||
( ()
|
||||
, onSuccessSend [ file templates ]
|
||||
, onSuccessSend [ file templates basePath ]
|
||||
)
|
||||
, update =
|
||||
\_ model ->
|
||||
@ -167,8 +168,8 @@ routeToPath routes =
|
||||
)
|
||||
|
||||
|
||||
file : List (List String) -> Elm.File
|
||||
file templates =
|
||||
file : List (List String) -> String -> Elm.File
|
||||
file templates basePath =
|
||||
let
|
||||
routes : List RoutePattern.RoutePattern
|
||||
routes =
|
||||
@ -201,7 +202,7 @@ file templates =
|
||||
)
|
||||
)
|
||||
|> expose
|
||||
, Elm.declaration "baseUrl" (Elm.string "/")
|
||||
, Elm.declaration "baseUrl" (Elm.string basePath)
|
||||
|> expose
|
||||
, maybeToList.declaration
|
||||
, routeToPath routes |> .declaration |> expose
|
||||
|
@ -38,7 +38,10 @@ async function generateTemplateModuleConnector(basePath, phase) {
|
||||
],
|
||||
};
|
||||
}
|
||||
const routesModuleNew = await runElmCodegenCli(sortTemplates(templates));
|
||||
const routesModuleNew = await runElmCodegenCli(
|
||||
sortTemplates(templates),
|
||||
basePath
|
||||
);
|
||||
|
||||
return {
|
||||
mainModule: `port module Main exposing (..)
|
||||
@ -1146,7 +1149,7 @@ redirectTo route =
|
||||
};
|
||||
}
|
||||
|
||||
async function runElmCodegenCli(templates) {
|
||||
async function runElmCodegenCli(templates, basePath) {
|
||||
// await runElmCodegenInstall();
|
||||
await compileCliApp(
|
||||
// { debug: true },
|
||||
@ -1166,7 +1169,9 @@ async function runElmCodegenCli(templates) {
|
||||
"./elm-stuff/elm-pages-codegen.js"
|
||||
)).Elm.Generate;
|
||||
|
||||
const app = elmPagesCodegen.init({ flags: { templates: templates } });
|
||||
const app = elmPagesCodegen.init({
|
||||
flags: { templates: templates, basePath },
|
||||
});
|
||||
if (app.ports.onSuccessSend) {
|
||||
app.ports.onSuccessSend.subscribe(resolve);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user