diff --git a/generator/src/elm-file-constants.js b/generator/src/elm-file-constants.js index 09f884e8..be66b18c 100644 --- a/generator/src/elm-file-constants.js +++ b/generator/src/elm-file-constants.js @@ -44,6 +44,7 @@ import Pages.Manifest exposing (DisplayMode, Orientation) import Pages.Manifest.Category as Category exposing (Category) import RawContent import Url.Parser as Url exposing ((), s) +import Pages.Document port toJsPort : Json.Encode.Value -> Cmd msg @@ -54,10 +55,8 @@ application : , update : userMsg -> userModel -> ( userModel, Cmd userMsg ) , subscriptions : userModel -> Sub userMsg , view : userModel -> List ( List String, metadata ) -> Page metadata view -> { title : String, body : Html userMsg } - , parser : Pages.Parser metadata view , head : metadata -> List Head.Tag - , frontmatterParser : Json.Decode.Decoder metadata - , markdownToHtml : String -> view + , document : Pages.Document.Document metadata view , manifest : { backgroundColor : Maybe Color , categories : List Category @@ -79,10 +78,8 @@ application config = , view = config.view , update = config.update , subscriptions = config.subscriptions - , parser = config.parser - , frontmatterParser = config.frontmatterParser + , document = config.document , content = RawContent.content - , markdownToHtml = config.markdownToHtml , toJsPort = toJsPort , head = config.head , manifest = @@ -119,6 +116,7 @@ import Pages.Manifest exposing (DisplayMode, Orientation) import Pages.Manifest.Category as Category exposing (Category) import RawContent import Url.Parser as Url exposing ((), s) +import Pages.Document port toJsPort : Json.Encode.Value -> Cmd msg @@ -129,10 +127,8 @@ application : , update : userMsg -> userModel -> ( userModel, Cmd userMsg ) , subscriptions : userModel -> Sub userMsg , view : userModel -> List ( List String, metadata ) -> Page metadata view -> { title : String, body : Html userMsg } - , parser : Pages.Parser metadata view + , document : Pages.Document.Document metadata view , head : metadata -> List Head.Tag - , frontmatterParser : Json.Decode.Decoder metadata - , markdownToHtml : String -> view , manifest : { backgroundColor : Maybe Color , categories : List Category @@ -154,10 +150,8 @@ application config = , view = config.view , update = config.update , subscriptions = config.subscriptions - , parser = config.parser - , frontmatterParser = config.frontmatterParser + , document = config.document , content = RawContent.content - , markdownToHtml = config.markdownToHtml , toJsPort = toJsPort , head = config.head , manifest = diff --git a/generator/src/elm-pages.js b/generator/src/elm-pages.js index a7283768..1a1354a9 100755 --- a/generator/src/elm-pages.js +++ b/generator/src/elm-pages.js @@ -46,13 +46,23 @@ function unpackMarkup(path) { fs.readFileSync(path).toString(), markupFrontmatterOptions ); - return { path, metadata: separated.matter, body: separated.content }; + return { + path, + metadata: separated.matter, + body: separated.content, + extension: "emu" + }; } function parseMarkdown(path, fileContents) { console.log("!!! 3"); const { content, data } = matter(fileContents, markupFrontmatterOptions); - return { path, metadata: JSON.stringify(data), body: content }; + return { + path, + metadata: JSON.stringify(data), + body: content, + extension: "md" + }; } function run() { diff --git a/generator/src/generate-raw-content.js b/generator/src/generate-raw-content.js index 92a74955..062fa6d2 100644 --- a/generator/src/generate-raw-content.js +++ b/generator/src/generate-raw-content.js @@ -4,21 +4,11 @@ module.exports = function(markdown, markup) { import Dict exposing (Dict) -content : { markdown : List ( List String, { frontMatter : String, body : Maybe String } ), markup : List ( List String, { frontMatter : String, body : Maybe String } ) } +content : List ( List String, { extension: String, frontMatter : String, body : Maybe String } ) content = - { markdown = markdown, markup = markup } - - -markdown : List ( List String, { frontMatter : String, body : Maybe String } ) -markdown = - [ ${markdown.map(toEntry)} + [ ${markdown.concat(markup).map(toEntry)} ] - - -markup : List ( List String, { frontMatter : String, body : Maybe String } ) -markup = - [ ${markup.map(toEntry)} - ]`; + `; }; function toEntry(entry) { @@ -32,6 +22,8 @@ function toEntry(entry) { return ` ( [${fullPath.join(", ")}] , { frontMatter = """${entry.metadata} -""", body = Nothing } ) +""" , body = Nothing + , extension = "${entry.extension}" + } ) `; }