mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 23:06:10 +03:00
Change the way that elmTypes are generated for static route record.
This commit is contained in:
parent
565925c44e
commit
5ddb958085
@ -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 ) }
|
||||
|
@ -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} `;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user