Remove hardcoding of init function.

This commit is contained in:
Dillon Kearns 2020-08-23 07:21:40 -07:00
parent 15a8881eec
commit 56028a1d41
2 changed files with 20 additions and 32 deletions

View File

@ -117,30 +117,12 @@ init maybePagePath =
Just meta ->
case meta of
M.MetadataBlogPost metadata ->
Template.BlogPost.template.init metadata
${templates.map(name => `M.Metadata${name} metadata ->
Template.${name}.template.init metadata
|> Tuple.first
|> ModelBlogPost
|> Model${name}
M.MetadataShowcase metadata ->
Template.Showcase.template.init metadata
|> Tuple.first
|> ModelShowcase
M.MetadataPage metadata ->
Template.Page.template.init metadata
|> Tuple.first
|> ModelPage
M.MetadataBlogIndex metadata ->
Template.BlogIndex.template.init metadata
|> Tuple.first
|> ModelBlogIndex
M.MetadataDocumentation metadata ->
Template.Documentation.template.init metadata
|> Tuple.first
|> ModelDocumentation
`).join("\n ")}
}
, Cmd.none
)

View File

@ -379,30 +379,36 @@ init maybePagePath =
Just meta ->
case meta of
M.MetadataBlogIndex metadata ->
Template.BlogIndex.template.init metadata
|> Tuple.first
|> ModelBlogIndex
M.MetadataBlogPost metadata ->
Template.BlogPost.template.init metadata
|> Tuple.first
|> ModelBlogPost
M.MetadataShowcase metadata ->
Template.Showcase.template.init metadata
M.MetadataDocumentation metadata ->
Template.Documentation.template.init metadata
|> Tuple.first
|> ModelShowcase
|> ModelDocumentation
M.MetadataPage metadata ->
Template.Page.template.init metadata
|> Tuple.first
|> ModelPage
M.MetadataBlogIndex metadata ->
Template.BlogIndex.template.init metadata
|> Tuple.first
|> ModelBlogIndex
M.MetadataDocumentation metadata ->
Template.Documentation.template.init metadata
M.MetadataShowcase metadata ->
Template.Showcase.template.init metadata
|> Tuple.first
|> ModelDocumentation
|> ModelShowcase
}
, Cmd.none
)