2021-07-21 23:29:45 +03:00
|
|
|
module Page.FileData exposing (Data, Model, Msg, page)
|
|
|
|
|
|
|
|
import DataSource exposing (DataSource)
|
|
|
|
import DataSource.File
|
|
|
|
import Head
|
|
|
|
import Head.Seo as Seo
|
|
|
|
import Html.Styled exposing (text)
|
2022-02-25 21:04:19 +03:00
|
|
|
import Json.Decode as Decode
|
2021-07-21 23:29:45 +03:00
|
|
|
import Page exposing (Page, PageWithState, StaticPayload)
|
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Pages.Url
|
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
2021-12-10 22:10:24 +03:00
|
|
|
{}
|
2021-07-21 23:29:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
2022-02-25 21:04:19 +03:00
|
|
|
()
|
2021-07-21 23:29:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
page : Page RouteParams Data
|
|
|
|
page =
|
|
|
|
Page.single
|
|
|
|
{ head = head
|
|
|
|
, data = data
|
|
|
|
}
|
|
|
|
|> Page.buildNoState { view = view }
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
{ greeting : String
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
data : DataSource Data
|
|
|
|
data =
|
|
|
|
"my-json-data.json"
|
|
|
|
|> DataSource.File.jsonFile (Decode.field "greeting" Decode.string)
|
|
|
|
|> DataSource.map Data
|
|
|
|
|
|
|
|
|
|
|
|
head :
|
|
|
|
StaticPayload Data RouteParams
|
|
|
|
-> List Head.Tag
|
|
|
|
head static =
|
|
|
|
Seo.summary
|
|
|
|
{ canonicalUrlOverride = Nothing
|
|
|
|
, siteName = "elm-pages"
|
|
|
|
, image =
|
|
|
|
{ url = Pages.Url.external "TODO"
|
|
|
|
, alt = "elm-pages logo"
|
|
|
|
, dimensions = Nothing
|
|
|
|
, mimeType = Nothing
|
|
|
|
}
|
|
|
|
, description = "TODO"
|
|
|
|
, locale = Nothing
|
|
|
|
, title = "TODO title" -- metadata.title -- TODO
|
|
|
|
}
|
|
|
|
|> Seo.website
|
|
|
|
|
|
|
|
|
|
|
|
view :
|
|
|
|
Maybe PageUrl
|
|
|
|
-> Shared.Model
|
|
|
|
-> StaticPayload Data RouteParams
|
|
|
|
-> View Msg
|
|
|
|
view maybeUrl sharedModel static =
|
|
|
|
{ title = "Index page"
|
|
|
|
, body =
|
|
|
|
[ text <| "Greeting: " ++ static.data.greeting
|
|
|
|
]
|
|
|
|
}
|