Remove TemplateType.

This commit is contained in:
Dillon Kearns 2021-04-02 15:29:59 -07:00
parent 3ee8e5b165
commit 3372c04e0d
10 changed files with 16 additions and 138 deletions

View File

@ -11,7 +11,6 @@ import Pages.ImagePath exposing (ImagePath)
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.StaticFile as StaticFile
import Pages.StaticHttp as StaticHttp
import TemplateType exposing (TemplateType)
type alias BlogPost =

View File

@ -3,18 +3,15 @@ module DocSidebar exposing (view)
import Element exposing (Element)
import Element.Border as Border
import Element.Font
import Metadata exposing (Metadata)
import Pages
import Pages.PagePath as PagePath exposing (PagePath)
import Palette
import TemplateType exposing (TemplateType)
view :
PagePath Pages.PathKey
-> List ( PagePath Pages.PathKey, TemplateType )
-> Element msg
view currentPage posts =
view currentPage =
Element.column
[ Element.spacing 10
, Border.widthEach { bottom = 0, left = 0, right = 1, top = 0 }
@ -22,18 +19,22 @@ view currentPage posts =
, Element.padding 12
, Element.height Element.fill
]
(posts
|> List.filterMap
(\( path, metadata ) ->
case metadata of
TemplateType.Documentation meta ->
Just ( currentPage == path, path, meta )
[]
_ ->
Nothing
)
|> List.map postSummary
)
--(posts
-- |> List.filterMap
-- (\( path, metadata ) ->
-- case metadata of
-- TemplateType.Documentation meta ->
-- Just ( currentPage == path, path, meta )
--
-- _ ->
-- Nothing
-- )
-- |> List.map postSummary
--)
postSummary :

View File

@ -1,7 +1,5 @@
module Index exposing (view)
--import Pages.Metadata as Metadata exposing (Metadata)
import Article
import Data.Author
import Date
@ -11,8 +9,6 @@ import Element.Font
import Pages
import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.PagePath as PagePath exposing (PagePath)
import TemplateMetadata exposing (BlogPost)
import TemplateType exposing (TemplateType)
view :

View File

@ -4,9 +4,6 @@ import Cloudinary
import Color
import Data.Author
import Head
import Json.Decode
import MarkdownRenderer
import MetadataNew
import MimeType
import MySitemap
import NoMetadata exposing (NoMetadata(..))
@ -21,7 +18,6 @@ import RssPlugin
import Shared
import Site
import TemplateModulesBeta
import TemplateType exposing (TemplateType)
webp : MimeType.MimeImage

View File

@ -1,81 +0,0 @@
module MetadataNew exposing (DocMetadata, PageMetadata, decoder)
import Cloudinary
import Data.Author
import Date exposing (Date)
import Json.Decode as Decode exposing (Decoder)
import Pages
import Pages.ImagePath exposing (ImagePath)
import Template.BlogPost
import Template.Page
import Template.Showcase
import TemplateType exposing (TemplateType)
type alias DocMetadata =
{ title : String
}
type alias PageMetadata =
{ title : String }
type alias ArticleMetadata =
{ title : String
, description : String
, published : Date
, author : Data.Author.Author
, image : ImagePath Pages.PathKey
, draft : Bool
}
decoder : Decoder TemplateType
decoder =
Decode.field "type" Decode.string
|> Decode.andThen
(\pageType ->
case pageType of
"doc" ->
Decode.field "title" Decode.string
|> Decode.map (\title -> TemplateType.Documentation { title = title })
"blog-index" ->
Decode.succeed {}
|> Decode.map TemplateType.BlogIndex
"blog" ->
Decode.map6 ArticleMetadata
(Decode.field "title" Decode.string)
(Decode.field "description" Decode.string)
(Decode.field "published"
(Decode.string
|> Decode.andThen
(\isoString ->
case Date.fromIsoString isoString of
Ok date ->
Decode.succeed date
Err error ->
Decode.fail error
)
)
)
(Decode.field "author" Data.Author.decoder)
(Decode.field "image" imageDecoder)
(Decode.field "draft" Decode.bool
|> Decode.maybe
|> Decode.map (Maybe.withDefault False)
)
|> Decode.map TemplateType.BlogPost
_ ->
Decode.fail <| "Unexpected page \"type\" " ++ pageType
)
imageDecoder : Decoder (ImagePath Pages.PathKey)
imageDecoder =
Decode.string
|> Decode.map (\cloudinaryAsset -> Cloudinary.url cloudinaryAsset Nothing 800)

View File

@ -9,7 +9,6 @@ import Pages.Manifest as Manifest
import Pages.Manifest.Category
import Pages.PagePath exposing (PagePath)
import Pages.StaticHttp as StaticHttp
import TemplateType exposing (TemplateType)
type alias SiteConfig =
@ -29,13 +28,6 @@ type alias StaticData =
()
staticData :
List ( PagePath Pages.PathKey, TemplateType )
-> StaticHttp.Request StaticData
staticData siteMetadata =
StaticHttp.succeed ()
canonicalUrl : String
canonicalUrl =
"https://elm-pages.com"

View File

@ -17,7 +17,6 @@ import Palette
import Shared
import Site
import Template exposing (StaticPayload, TemplateWithState)
import TemplateType exposing (TemplateType)
type alias Documentation =
@ -59,13 +58,6 @@ update _ msg model sharedModel =
( model, Cmd.none, Just Shared.IncrementFromChild )
staticData :
List ( PagePath Pages.PathKey, TemplateType )
-> StaticHttp.Request StaticData
staticData siteMetadata =
StaticHttp.succeed ()
decoder : Decode.Decoder Documentation
decoder =
Decode.map Documentation
@ -102,7 +94,6 @@ view model sharedModel staticPayload =
[ --counterView sharedModel,
DocSidebar.view
staticPayload.path
[]
-- allMetadata -- TODO
|> 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 ]

View File

@ -3,18 +3,14 @@ module Template.Showcase exposing (Model, Msg, template)
import Element exposing (Element)
import Head
import Head.Seo as Seo
import Json.Decode as Decode exposing (Decoder)
import MarkdownRenderer
import OptimizedDecoder
import Pages exposing (images)
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.StaticFile as StaticFile
import Pages.StaticHttp as StaticHttp
import Secrets
import Shared
import Showcase
import Template exposing (StaticPayload, TemplateWithState)
import TemplateType exposing (TemplateType)
type alias Model =

View File

@ -1,11 +0,0 @@
module TemplateType exposing (TemplateType(..))
import TemplateMetadata
type TemplateType
= BlogPost TemplateMetadata.BlogPost
| Showcase TemplateMetadata.Showcase
| Page TemplateMetadata.Page
| BlogIndex TemplateMetadata.BlogIndex
| Documentation TemplateMetadata.Documentation

View File

@ -12,7 +12,6 @@ import Browser
import Pages.Manifest as Manifest
import Shared
import NoMetadata exposing (NoMetadata(..))
import TemplateType as M exposing (TemplateType)
import Head
import Html exposing (Html)
import Pages