Files
elm-0.19-workshop/part10/Page.elm
Richard Feldman 18b8723f16 SPA for part10
2016-09-01 06:39:06 -07:00

27 lines
516 B
Elm

module Page exposing (..)
import Navigation
import UrlParser exposing (Parser, (</>), format, int, s, string)
import String
type Page
= Home
| Repository Int
| NotFound
pageParser : Parser (Page -> a) a
pageParser =
UrlParser.oneOf
[ format Home (s "")
, format Repository (s "repositories" </> int)
]
parser : Navigation.Location -> Result String Page
parser location =
location.pathname
|> String.dropLeft 1
|> UrlParser.parse identity pageParser