Change the way that elmTypes are generated for static route record.

This commit is contained in:
Dillon Kearns 2019-08-20 08:43:38 -07:00
parent 565925c44e
commit 5ddb958085
2 changed files with 10 additions and 5 deletions

View File

@ -95,9 +95,9 @@ generate : List Page -> List MarkdownContent -> String
generate content markdownContent =
interpolate """module RawContent exposing (content)
import Pages.Content as Content exposing (Content)
import Dict exposing (Dict)
import Element exposing (Element)
import Url.Parser as Url exposing ((</>), s)
content : { markdown : List ( List String, { frontMatter : String, body : Maybe String } ), markup : List ( List String, String ) }

View File

@ -55,7 +55,11 @@ function generate(scanned) {
pathFragments = pathFragments.replace(/\.[^/.]+$/, "").split(path.sep);
const ext = path.extname(scanned[i].path);
if (scanned[i].document) {
const elmType = pathFragments.map(toPascalCase).join("");
// const elmType = pathFragments.map(toPascalCase).join("");
const elmType =
"(PageRoute [ " +
pathFragments.map(fragment => `"${fragment}"`).join(", ") +
" ])";
captureRouteRecord(pathFragments, elmType, routeRecord);
allRoutes.push(elmType);
urlParser.push(formatUrlParser(elmType, pathFragments));
@ -148,7 +152,7 @@ function captureRouteRecord(pieces, elmType, record) {
function formatAsElmList(name, items) {
var formatted = items.join("\n , ");
var signature = name + " : List Route\n";
var signature = name + " : List PageRoute\n";
return signature + name + " =\n [ " + formatted + "\n ]";
}
@ -197,5 +201,6 @@ function formatAsElmUrlParser(pieces) {
var parser =
" [ " + pieces.map(p => p.parser).join("\n , ") + "\n ]";
return `urlParser =\n Url.oneOf\n ${parser} `;
return `urlParser : Url.Parser (PageRoute -> a) a
urlParser =\n Url.oneOf\n ${parser} `;
}