diff --git a/generator/src/generate-template-module-connector.js b/generator/src/generate-template-module-connector.js index a33580d6..7195dcad 100644 --- a/generator/src/generate-template-module-connector.js +++ b/generator/src/generate-template-module-connector.js @@ -168,12 +168,25 @@ update msg model = _ -> ( model.page, Cmd.none ) in - ( { model | page = updatedPageModel }, pageCmd ) + ( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd ) ` ).join("\n ")} +save : TemplateModel -> Global.Model -> Global.Model +save model globalModel= + case model of + ${templates.map(name => `Model${name} m -> + Template.${name}.template.save m globalModel +` + ).join("\n ")} + + NotFound -> + globalModel + + + mainTemplate { documents, manifest, canonicalSiteUrl, subscriptions } = Pages.Platform.init { init = init diff --git a/tests/__snapshots__/generated-files.test.js.snap b/tests/__snapshots__/generated-files.test.js.snap index 808836e7..e851b40d 100644 --- a/tests/__snapshots__/generated-files.test.js.snap +++ b/tests/__snapshots__/generated-files.test.js.snap @@ -446,7 +446,7 @@ update msg model = _ -> ( model.page, Cmd.none ) in - ( { model | page = updatedPageModel }, pageCmd ) + ( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd ) MsgBlogPost msg_ -> @@ -463,7 +463,7 @@ update msg model = _ -> ( model.page, Cmd.none ) in - ( { model | page = updatedPageModel }, pageCmd ) + ( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd ) MsgDocumentation msg_ -> @@ -480,7 +480,7 @@ update msg model = _ -> ( model.page, Cmd.none ) in - ( { model | page = updatedPageModel }, pageCmd ) + ( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd ) MsgPage msg_ -> @@ -497,7 +497,7 @@ update msg model = _ -> ( model.page, Cmd.none ) in - ( { model | page = updatedPageModel }, pageCmd ) + ( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd ) MsgShowcase msg_ -> @@ -514,11 +514,35 @@ update msg model = _ -> ( model.page, Cmd.none ) in - ( { model | page = updatedPageModel }, pageCmd ) + ( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd ) +save : TemplateModel -> Global.Model -> Global.Model +save model globalModel= + case model of + ModelBlogIndex m -> + Template.BlogIndex.template.save m globalModel + + ModelBlogPost m -> + Template.BlogPost.template.save m globalModel + + ModelDocumentation m -> + Template.Documentation.template.save m globalModel + + ModelPage m -> + Template.Page.template.save m globalModel + + ModelShowcase m -> + Template.Showcase.template.save m globalModel + + + NotFound -> + globalModel + + + mainTemplate { documents, manifest, canonicalSiteUrl, subscriptions } = Pages.Platform.init { init = init