Update part12

This commit is contained in:
Richard Feldman
2016-09-03 00:09:20 -07:00
parent cb13ef5ffb
commit d2f958151a
10 changed files with 555 additions and 12 deletions

26
part12/Page.elm Normal file
View File

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