Do example of hardcoded static data.

This commit is contained in:
Dillon Kearns 2019-10-14 08:04:12 -07:00
parent 8037ed33f5
commit ebc80239a8
2 changed files with 114 additions and 133 deletions

View File

@ -111,7 +111,7 @@ view :
} }
-> ->
{ view : { view :
() Int
-> Model -> Model
-> View -> View
-> ->
@ -119,151 +119,131 @@ view :
, body : Html Msg , body : Html Msg
} }
, head : List (Head.Tag Pages.PathKey) , head : List (Head.Tag Pages.PathKey)
, staticRequest : StaticHttp.Request () , staticRequest : StaticHttp.Request Int
} }
view siteMetadata page = view siteMetadata page =
let let
viewFn = viewFn =
\() model viewForPage -> \staticData model viewForPage ->
pageView model (case page.frontmatter of
siteMetadata Metadata.Page metadata ->
{ path = page.path { title = metadata.title
, metadata = page.frontmatter , body =
, view = Element.text <| "The value is: " ++ String.fromInt staticData
viewForPage
} -- [
-- header page.path
-- , Element.column
-- [ Element.padding 50
-- , Element.spacing 60
-- , Element.Region.mainContent
-- ]
-- (Tuple.second viewForPage)
-- ]
-- |> Element.textColumn
-- [ Element.width Element.fill
-- ]
}
Metadata.Article metadata ->
{ title = metadata.title
, body =
Element.column [ Element.width Element.fill ]
[ header page.path
, Element.column
[ Element.padding 30
, Element.spacing 40
, Element.Region.mainContent
, Element.width (Element.fill |> Element.maximum 800)
, Element.centerX
]
(Element.column [ Element.spacing 10 ]
[ Element.row [ Element.spacing 10 ]
[ Author.view [] metadata.author
, Element.column [ Element.spacing 10, Element.width Element.fill ]
[ Element.paragraph [ Font.bold, Font.size 24 ]
[ Element.text metadata.author.name
]
, Element.paragraph [ Font.size 16 ]
[ Element.text metadata.author.bio ]
]
]
]
:: (publishedDateView metadata |> Element.el [ Font.size 16, Font.color (Element.rgba255 0 0 0 0.6) ])
:: Palette.blogHeading metadata.title
:: articleImageView metadata.image
:: Tuple.second viewForPage
)
]
}
Metadata.Doc metadata ->
{ title = metadata.title
, body =
[ header page.path
, Element.row []
[ DocSidebar.view page.path siteMetadata
|> Element.el [ Element.width (Element.fillPortion 2), Element.alignTop, Element.height Element.fill ]
, Element.column [ Element.width (Element.fillPortion 8), Element.padding 35, Element.spacing 15 ]
[ Palette.heading 1 [ Element.text metadata.title ]
, Element.column [ Element.spacing 20 ]
[ tocView (Tuple.first viewForPage)
, Element.column
[ Element.padding 50
, Element.spacing 30
, Element.Region.mainContent
]
(Tuple.second viewForPage)
]
]
]
]
|> Element.textColumn
[ Element.width Element.fill
, Element.height Element.fill
]
}
Metadata.Author author ->
{ title = author.name
, body =
Element.column
[ Element.width Element.fill
]
[ header page.path
, Element.column
[ Element.padding 30
, Element.spacing 20
, Element.Region.mainContent
, Element.width (Element.fill |> Element.maximum 800)
, Element.centerX
]
[ Palette.blogHeading author.name
, Author.view [] author
, Element.paragraph [ Element.centerX, Font.center ] (Tuple.second viewForPage)
]
]
}
Metadata.BlogIndex ->
{ title = "elm-pages blog"
, body =
Element.column [ Element.width Element.fill ]
[ header page.path
, Element.column [ Element.padding 20, Element.centerX ] [ Index.view siteMetadata ]
]
}
)
|> wrapBody |> wrapBody
in in
{ view = { view =
viewFn viewFn
, head = , head =
head page.frontmatter head page.frontmatter
, staticRequest = StaticHttp.none , staticRequest = StaticHttp.get "" (\_ -> 123)
-- title = title
-- , body =
-- body
} }
--Model
-- -> view
-- ->
-- { title : String
-- , body : Html Msg
-- }
pageView : Model -> List ( PagePath Pages.PathKey, Metadata ) -> Page Metadata ( MarkdownRenderer.TableOfContents, List (Element Msg) ) Pages.PathKey -> { title : String, body : Element Msg }
pageView model siteMetadata page =
case page.metadata of
Metadata.Page metadata ->
{ title = metadata.title
, body =
[ header page.path
, Element.column
[ Element.padding 50
, Element.spacing 60
, Element.Region.mainContent
]
(Tuple.second page.view)
]
|> Element.textColumn
[ Element.width Element.fill
]
}
Metadata.Article metadata ->
{ title = metadata.title
, body =
Element.column [ Element.width Element.fill ]
[ header page.path
, Element.column
[ Element.padding 30
, Element.spacing 40
, Element.Region.mainContent
, Element.width (Element.fill |> Element.maximum 800)
, Element.centerX
]
(Element.column [ Element.spacing 10 ]
[ Element.row [ Element.spacing 10 ]
[ Author.view [] metadata.author
, Element.column [ Element.spacing 10, Element.width Element.fill ]
[ Element.paragraph [ Font.bold, Font.size 24 ]
[ Element.text metadata.author.name
]
, Element.paragraph [ Font.size 16 ]
[ Element.text metadata.author.bio ]
]
]
]
:: (publishedDateView metadata |> Element.el [ Font.size 16, Font.color (Element.rgba255 0 0 0 0.6) ])
:: Palette.blogHeading metadata.title
:: articleImageView metadata.image
:: Tuple.second page.view
)
]
}
Metadata.Doc metadata ->
{ title = metadata.title
, body =
[ header page.path
, Element.row []
[ DocSidebar.view page.path siteMetadata
|> Element.el [ Element.width (Element.fillPortion 2), Element.alignTop, Element.height Element.fill ]
, Element.column [ Element.width (Element.fillPortion 8), Element.padding 35, Element.spacing 15 ]
[ Palette.heading 1 [ Element.text metadata.title ]
, Element.column [ Element.spacing 20 ]
[ tocView (Tuple.first page.view)
, Element.column
[ Element.padding 50
, Element.spacing 30
, Element.Region.mainContent
]
(Tuple.second page.view)
]
]
]
]
|> Element.textColumn
[ Element.width Element.fill
, Element.height Element.fill
]
}
Metadata.Author author ->
{ title = author.name
, body =
Element.column
[ Element.width Element.fill
]
[ header page.path
, Element.column
[ Element.padding 30
, Element.spacing 20
, Element.Region.mainContent
, Element.width (Element.fill |> Element.maximum 800)
, Element.centerX
]
[ Palette.blogHeading author.name
, Author.view [] author
, Element.paragraph [ Element.centerX, Font.center ] (Tuple.second page.view)
]
]
}
Metadata.BlogIndex ->
{ title = "elm-pages blog"
, body =
Element.column [ Element.width Element.fill ]
[ header page.path
, Element.column [ Element.padding 20, Element.centerX ] [ Index.view siteMetadata ]
]
}
wrapBody { body, title } = wrapBody { body, title } =
{ body = { body =
body body

View File

@ -156,6 +156,7 @@ import Pages.Document as Document
import Pages.ImagePath as ImagePath exposing (ImagePath) import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.PagePath as PagePath exposing (PagePath) import Pages.PagePath as PagePath exposing (PagePath)
import Pages.Directory as Directory exposing (Directory) import Pages.Directory as Directory exposing (Directory)
import Pages.StaticHttp as StaticHttp
type PathKey type PathKey