Fix title of the app before it loads (#97)

and improve window title per page

fixes #93
This commit is contained in:
Rok Garbas 2020-06-12 12:20:28 +02:00 committed by GitHub
parent 9f3de349e8
commit 2daa4b0d8b
Failed to generate hash of commit
2 changed files with 47 additions and 30 deletions

View file

@ -252,39 +252,60 @@ update msg model =
-- VIEW
view : Model -> Html Msg
view :
Model
->
{ title : String
, body : List (Html Msg)
}
view model =
div []
[ header []
[ div [ class "navbar navbar-static-top" ]
[ div [ class "navbar-inner" ]
[ div [ class "container" ]
[ a [ class "brand", href "https://nixos.org" ]
[ img [ src "https://nixos.org/logo/nix-wiki.png", class "logo" ] []
]
, div [ class "nav-collapse collapse" ]
[ ul [ class "nav pull-left" ]
(viewNavigation model.page model.url)
let
title =
case model.page of
Packages _ ->
"NixOS Search - Packages"
Options _ ->
"NixOS Search - Options"
_ ->
"NixOS Search"
in
{ title = title
, body =
[ div []
[ header []
[ div [ class "navbar navbar-static-top" ]
[ div [ class "navbar-inner" ]
[ div [ class "container" ]
[ a [ class "brand", href "https://nixos.org" ]
[ img [ src "https://nixos.org/logo/nix-wiki.png", class "logo" ] []
]
, div [ class "nav-collapse collapse" ]
[ ul [ class "nav pull-left" ]
(viewNavigation model.page model.url)
]
]
]
]
]
]
, div [ class "container main" ]
[ div [ id "content" ] [ viewPage model ]
, footer
[ class "container text-center" ]
[ div []
[ span [] [ text "Elasticsearch instance graciously provided by " ]
, a [ href "https://bonsai.io" ] [ text "Bonsai" ]
, span [] [ text "." ]
]
, div []
[ span [] [ text " Thank you " ]
, div [ class "container main" ]
[ div [ id "content" ] [ viewPage model ]
, footer
[ class "container text-center" ]
[ div []
[ span [] [ text "Elasticsearch instance graciously provided by " ]
, a [ href "https://bonsai.io" ] [ text "Bonsai" ]
, span [] [ text "." ]
]
, div []
[ span [] [ text " Thank you " ]
]
]
]
]
]
}
viewNavigation : Page -> Url.Url -> List (Html Msg)
@ -367,9 +388,5 @@ main =
, onUrlChange = ChangedUrl
, subscriptions = subscriptions
, update = update
, view =
\m ->
{ title = "NixOS Search"
, body = [ view m ]
}
, view = view
}

View file

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Elm hotloading dev environment</title>
<title>NixOS Search - Loading...</title>
<script type="text/javascript" src="https://nixos.org/js/jquery.min.js"></script>