mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 23:06:10 +03:00
Fix static routes for prerendering.
This commit is contained in:
parent
e770d19254
commit
8408ac60d5
@ -102,6 +102,7 @@ function run() {
|
||||
|
||||
app.ports.writeFile.subscribe(contents => {
|
||||
const rawContent = generateRawContent(markdownContent, content);
|
||||
const routes = toRoutes(markdownContent.concat(content));
|
||||
|
||||
fs.writeFileSync("./gen/RawContent.elm", rawContent);
|
||||
fs.writeFileSync("./gen/PagesNew.elm", elmPagesUiFile(staticRoutes));
|
||||
@ -112,7 +113,7 @@ function run() {
|
||||
if (!devServerRunning) {
|
||||
devServerRunning = true;
|
||||
develop.start({
|
||||
routes: contents.routes,
|
||||
routes,
|
||||
debug: contents.debug,
|
||||
manifestConfig
|
||||
});
|
||||
@ -120,7 +121,7 @@ function run() {
|
||||
} else {
|
||||
develop.run(
|
||||
{
|
||||
routes: contents.routes,
|
||||
routes,
|
||||
manifestConfig
|
||||
},
|
||||
() => {}
|
||||
@ -149,3 +150,16 @@ function startWatchIfNeeded() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function toRoutes(entries) {
|
||||
return entries.map(toRoute);
|
||||
}
|
||||
|
||||
function toRoute(entry) {
|
||||
let fullPath = entry.path
|
||||
.replace(/(index)?\.[^/.]+$/, "")
|
||||
.split("/")
|
||||
.filter(item => item !== "");
|
||||
fullPath.splice(0, 1);
|
||||
return `/${fullPath.join("/")}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user