Wire in blog index with an empty list of posts for now.

This commit is contained in:
Dillon Kearns 2020-05-24 12:33:17 -07:00
parent 8a9cc44a2b
commit 2ff13c00e3
7 changed files with 174 additions and 184 deletions

View File

@ -0,0 +1,13 @@
module AllMetadata exposing (..)
import Template.BlogIndex
import Template.BlogPost
import Template.Page
import Template.Showcase
type Metadata
= MetadataBlogPost Template.BlogPost.Metadata
| MetadataShowcase Template.Showcase.Metadata
| MetadataPage Template.Page.Metadata
| MetadataBlogIndex Template.BlogIndex.Metadata

View File

@ -1,15 +1,17 @@
module Index exposing (view)
--import Pages.Metadata as Metadata exposing (Metadata)
import Data.Author
import Date
import Element exposing (Element)
import Element.Border
import Element.Font
import Metadata exposing (Metadata)
import Pages
import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.Platform exposing (Page)
import Template.BlogPost exposing (Metadata)
view :
@ -20,16 +22,11 @@ view posts =
(posts
|> List.filterMap
(\( path, metadata ) ->
case metadata of
Metadata.Article meta ->
if meta.draft then
Nothing
if metadata.draft then
Nothing
else
Just ( path, meta )
_ ->
Nothing
else
Just ( path, metadata )
)
|> List.sortBy
(\( path, metadata ) ->
@ -42,7 +39,7 @@ view posts =
postSummary :
( PagePath Pages.PathKey, Metadata.ArticleMetadata )
( PagePath Pages.PathKey, Metadata )
-> Element msg
postSummary ( postPath, post ) =
articleIndex post |> linkToPost postPath
@ -66,7 +63,7 @@ title text =
]
articleIndex : Metadata.ArticleMetadata -> Element msg
articleIndex : Metadata -> Element msg
articleIndex metadata =
Element.el
[ Element.centerX
@ -86,7 +83,7 @@ grey =
Element.Font.color (Element.rgba255 0 0 0 0.5)
postPreview : Metadata.ArticleMetadata -> Element msg
postPreview : Metadata -> Element msg
postPreview post =
Element.textColumn
[ Element.centerX

View File

@ -1,5 +1,6 @@
module Main exposing (main)
import AllMetadata
import Color
import Data.Author as Author
import Date
@ -54,7 +55,7 @@ manifest =
, iarcRatingId = Nothing
, name = "elm-pages docs"
, themeColor = Just Color.white
, startUrl = pages.index
, startUrl = pages.blog.staticHttp
, shortName = Just "elm-pages"
, sourceIcon = images.iconPng
}
@ -64,7 +65,7 @@ type alias View =
( MarkdownRenderer.TableOfContents, List (Element Msg) )
main : Pages.Platform.Program TemplateDemultiplexer.Model TemplateDemultiplexer.Msg TemplateDemultiplexer.Metadata TemplateDemultiplexer.View
main : Pages.Platform.Program TemplateDemultiplexer.Model TemplateDemultiplexer.Msg AllMetadata.Metadata TemplateDemultiplexer.View
main =
TemplateDemultiplexer.mainTemplate
{ documents =
@ -209,52 +210,6 @@ pageView :
-> { title : String, body : Element Msg }
pageView stars model siteMetadata page viewForPage =
case page.frontmatter of
Metadata.Page metadata ->
{ title = metadata.title
, body =
[ 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 ]
[ 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 =
@ -281,96 +236,8 @@ pageView stars model siteMetadata page viewForPage =
]
}
Metadata.BlogIndex ->
{ title = "elm-pages blog"
, body =
Element.column [ Element.width Element.fill ]
[ Element.column [ Element.padding 20, Element.centerX ] [ Index.view siteMetadata ]
]
}
Metadata.Showcase ->
{ title = "elm-pages blog"
, body =
Element.column [ Element.width Element.fill ]
[--, Element.column [ Element.padding 20, Element.centerX ] [ Showcase.view siteMetadata ]
]
}
wrapBody : Int -> { a | path : PagePath Pages.PathKey } -> Model -> { c | body : Element Msg, title : String } -> { body : Html Msg, title : String }
wrapBody stars page model record =
{ body =
(if model.showMobileMenu then
Element.column
[ Element.width Element.fill
, Element.padding 20
]
[ Element.row [ Element.width Element.fill, Element.spaceEvenly ]
[ logoLinkMobile
, FontAwesome.styledIcon "fas fa-bars" [ Element.Events.onClick ToggleMobileMenu ]
]
, Element.column [ Element.centerX, Element.spacing 20 ]
(navbarLinks stars page.path)
]
else
Element.column [ Element.width Element.fill ]
[ header stars page.path
, record.body
]
)
|> Element.layout
[ Element.width Element.fill
, Font.size 20
, Font.family [ Font.typeface "Roboto" ]
, Font.color (Element.rgba255 0 0 0 0.8)
]
, title = record.title
}
articleImageView : ImagePath Pages.PathKey -> Element msg
articleImageView articleImage =
Element.image [ Element.width Element.fill ]
{ src = ImagePath.toString articleImage
, description = "Article cover photo"
}
header : Int -> PagePath Pages.PathKey -> Element Msg
header stars currentPath =
Element.column [ Element.width Element.fill ]
[ responsiveHeader
, Element.column
[ Element.width Element.fill
, Element.htmlAttribute (Attr.class "responsive-desktop")
]
[ Element.el
[ Element.height (Element.px 4)
, Element.width Element.fill
, Element.Background.gradient
{ angle = 0.2
, steps =
[ Element.rgb255 0 242 96
, Element.rgb255 5 117 230
]
}
]
Element.none
, Element.row
[ Element.paddingXY 25 4
, Element.spaceEvenly
, Element.width Element.fill
, Element.Region.navigation
, Element.Border.widthEach { bottom = 1, left = 0, right = 0, top = 0 }
, Element.Border.color (Element.rgba255 40 80 40 0.4)
]
[ logoLink
, Element.row [ Element.spacing 15 ] (navbarLinks stars currentPath)
]
]
]
_ ->
Debug.todo ""
logoLink =
@ -405,9 +272,10 @@ logoLinkMobile =
navbarLinks stars currentPath =
[ elmDocsLink
, githubRepoLink stars
, highlightableLink currentPath pages.docs.directory "Docs"
, highlightableLink currentPath pages.showcase.directory "Showcase"
, highlightableLink currentPath pages.blog.directory "Blog"
--, highlightableLink currentPath pages.docs.directory "Docs"
--, highlightableLink currentPath pages.showcase.directory "Showcase"
--, highlightableLink currentPath pages.blog.directory "Blog"
]

View File

@ -1,10 +1,11 @@
module MetadataNew exposing (DocMetadata, PageMetadata, decoder)
import AllMetadata as Metadata exposing (Metadata)
import Json.Decode as Decode exposing (Decoder)
import Template.BlogIndex
import Template.BlogPost
import Template.Page
import Template.Showcase
import TemplateDemultiplexer as TD exposing (Metadata)
type alias DocMetadata =
@ -28,14 +29,15 @@ decoder =
--
"page" ->
Template.Page.decoder
|> Decode.map TD.MetadataPage
|> Decode.map Metadata.MetadataPage
"blog-index" ->
Template.BlogIndex.decoder
|> Decode.map Metadata.MetadataBlogIndex
--
--"blog-index" ->
-- Decode.succeed BlogIndex
"showcase" ->
Template.Showcase.decoder
|> Decode.map TD.MetadataShowcase
|> Decode.map Metadata.MetadataShowcase
--
--"author" ->
@ -46,7 +48,7 @@ decoder =
-- |> Decode.map Author
"blog" ->
Template.BlogPost.decoder
|> Decode.map TD.MetadataBlogPost
|> Decode.map Metadata.MetadataBlogPost
_ ->
Decode.fail <| "Unexpected page \"type\" " ++ pageType

View File

@ -0,0 +1,86 @@
module Template.BlogIndex exposing (..)
import Element exposing (Element)
import Head
import Head.Seo as Seo
import Index
import Json.Decode as Decode exposing (Decoder)
import MarkdownRenderer
import Pages exposing (images)
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.StaticHttp as StaticHttp
import Showcase
import SiteConfig
type alias Metadata =
{}
type Msg
= Msg
decoder : Decoder Metadata
decoder =
Decode.succeed Metadata
staticData : a -> StaticHttp.Request StaticData
staticData siteMetadata =
Showcase.staticRequest
type alias StaticData =
List Showcase.Entry
init : Metadata -> Model
init metadata =
Model
type alias Model =
{}
type alias View msg =
( MarkdownRenderer.TableOfContents, List (Element msg) )
view : StaticData -> Model -> Metadata -> ( a, List (Element msg) ) -> { title : String, body : Element msg }
view data model metadata viewForPage =
{ title = "elm-pages blog"
, body =
Element.column [ Element.width Element.fill ]
[ Element.column [ Element.padding 20, Element.centerX ]
[ Index.view [] ]
]
}
--{ title = "elm-pages blog"
--, body =
-- Element.column [ Element.width Element.fill ]
-- [ Element.column [ Element.padding 20, Element.centerX ] [ Showcase.view data ]
-- ]
--}
head : StaticData -> PagePath.PagePath Pages.PathKey -> Metadata -> List (Head.Tag Pages.PathKey)
head static currentPath metadata =
Seo.summary
{ canonicalUrlOverride = Nothing
, siteName = "elm-pages"
, image =
{ url = images.iconPng
, alt = "elm-pages logo"
, dimensions = Nothing
, mimeType = Nothing
}
, description = SiteConfig.tagline
, locale = Nothing
, title = "elm-pages blog"
}
|> Seo.website

View File

@ -1,4 +1,4 @@
module Template.BlogPost exposing (Metadata(..), Model, Msg, decoder, head, init, liftViewMsg, staticData, template, view)
module Template.BlogPost exposing (Metadata, Model, Msg, decoder, head, init, liftViewMsg, staticData, template, view)
import Data.Author as Author exposing (Author)
import Date exposing (Date)
@ -21,11 +21,7 @@ import StructuredData
import Template
type Metadata
= Metadata MetadataRecord
type alias MetadataRecord =
type alias Metadata =
{ title : String
, description : String
, published : Date
@ -57,7 +53,7 @@ template =
decoder : Decode.Decoder Metadata
decoder =
Decode.map6 MetadataRecord
Decode.map6 Metadata
(Decode.field "title" Decode.string)
(Decode.field "description" Decode.string)
(Decode.field "published"
@ -79,7 +75,6 @@ decoder =
|> Decode.maybe
|> Decode.map (Maybe.withDefault False)
)
|> Decode.map Metadata
imageDecoder : Decode.Decoder (ImagePath Pages.PathKey)
@ -124,7 +119,7 @@ liftViewMsg liftMsg =
view : StaticData -> Model -> Metadata -> ( a, List (Element msg) ) -> { title : String, body : Element msg }
view static model (Metadata blogPost) rendered =
view static model blogPost rendered =
{ title = blogPost.title
, body =
Element.column [ Element.width Element.fill ]
@ -157,7 +152,7 @@ view static model (Metadata blogPost) rendered =
head : StaticData -> PagePath.PagePath Pages.PathKey -> Metadata -> List (Head.Tag Pages.PathKey)
head static currentPath (Metadata meta) =
head static currentPath meta =
Head.structuredData
(StructuredData.article
{ title = meta.title

View File

@ -1,27 +1,22 @@
module TemplateDemultiplexer exposing (..)
import AllMetadata as M exposing (Metadata)
import Element exposing (Element)
import Global
import Head
import Html exposing (Html)
import MarkdownRenderer
import Metadata
import Pages
import Pages.PagePath exposing (PagePath)
import Pages.Platform
import Pages.StaticHttp as StaticHttp
import SiteConfig
import Template.BlogIndex
import Template.BlogPost
import Template.Page
import Template.Showcase
type Metadata
= MetadataBlogPost Template.BlogPost.Metadata
| MetadataShowcase Template.Showcase.Metadata
| MetadataPage Template.Page.Metadata
type alias Model =
{ global : Global.Model
, page : TemplateModel
@ -32,6 +27,7 @@ type TemplateModel
= ModelBlogPost Template.BlogPost.Model
| ModelShowcase Template.Showcase.Model
| ModelPage Template.Page.Model
| ModelBlogIndex Template.BlogIndex.Model
type Msg
@ -62,7 +58,7 @@ view :
}
view siteMetadata page =
case page.frontmatter of
MetadataBlogPost metadata ->
M.MetadataBlogPost metadata ->
StaticHttp.map2
(\data globalData ->
{ view =
@ -91,7 +87,7 @@ view siteMetadata page =
(Template.BlogPost.staticData siteMetadata)
(Global.staticData siteMetadata)
MetadataShowcase metadata ->
M.MetadataShowcase metadata ->
StaticHttp.map2
(\data globalData ->
{ view =
@ -120,7 +116,7 @@ view siteMetadata page =
(Template.Showcase.staticData siteMetadata)
(Global.staticData siteMetadata)
MetadataPage metadata ->
M.MetadataPage metadata ->
StaticHttp.map2
(\data globalData ->
{ view =
@ -149,6 +145,35 @@ view siteMetadata page =
(Template.Page.staticData siteMetadata)
(Global.staticData siteMetadata)
M.MetadataBlogIndex metadata ->
StaticHttp.map2
(\data globalData ->
{ view =
\model rendered ->
case model.page of
ModelBlogIndex subModel ->
Template.BlogIndex.view data subModel metadata rendered
|> (\{ title, body } ->
Global.wrapBody
globalData
page
model.global
MsgGlobal
{ title = title
, body =
-- Template.BlogPost.liftViewMsg
body
}
)
_ ->
{ title = "", body = Html.text "" }
, head = Template.BlogIndex.head data page.path metadata
}
)
(Template.BlogIndex.staticData siteMetadata)
(Global.staticData siteMetadata)
init :
Maybe
@ -169,17 +194,21 @@ init maybePagePath =
Just meta ->
case meta of
MetadataBlogPost metadata ->
M.MetadataBlogPost metadata ->
Template.BlogPost.init metadata
|> ModelBlogPost
MetadataShowcase metadata ->
M.MetadataShowcase metadata ->
Template.Showcase.init metadata
|> ModelShowcase
MetadataPage metadata ->
M.MetadataPage metadata ->
Template.Page.init metadata
|> ModelPage
M.MetadataBlogIndex metadata ->
Template.BlogIndex.init metadata
|> ModelBlogIndex
}
, Cmd.none
)