mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 21:29:55 +03:00
Clean up domain view.
This commit is contained in:
parent
34db38420c
commit
8a3c787906
@ -11,7 +11,6 @@ import Html.Attributes as Attr
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Path exposing (Path)
|
||||
import Route
|
||||
import RouteBuilder exposing (StatefulRoute, StatelessRoute, StaticPayload)
|
||||
import Server.Request as Request
|
||||
import Server.Response as Response exposing (Response)
|
||||
@ -146,12 +145,8 @@ storyView story =
|
||||
[ Html.h1 []
|
||||
[ Html.text story.title ]
|
||||
]
|
||||
, Html.text " ("
|
||||
, Html.span
|
||||
[ Attr.class "host"
|
||||
]
|
||||
[ Html.text story.domain ]
|
||||
, Html.text ")"
|
||||
, Html.text " "
|
||||
, Story.domainView story.domain
|
||||
, Html.p
|
||||
[ Attr.class "meta"
|
||||
]
|
||||
|
@ -32,36 +32,27 @@ view story =
|
||||
, Html.span
|
||||
[ Attr.class "title"
|
||||
]
|
||||
(case story.url of
|
||||
Just url ->
|
||||
(case ( story.url, story.url |> Maybe.withDefault "" |> String.startsWith "item?id=" ) of
|
||||
( Just url, False ) ->
|
||||
[ Html.a
|
||||
[ Attr.href url
|
||||
, Attr.target "_blank"
|
||||
, Attr.rel "noreferrer"
|
||||
]
|
||||
[ Html.text story.title ]
|
||||
|
||||
{-
|
||||
{story.url && !story.url.startsWith("item?id=") ? (
|
||||
<>
|
||||
<a href={story.url} target="_blank" rel="noreferrer">
|
||||
{story.title}
|
||||
</a>
|
||||
<span class="host"> ({story.domain})</span>
|
||||
</>
|
||||
) : (
|
||||
<a href={`/item/${story.id}`}>{story.title}</a>
|
||||
)}
|
||||
-}
|
||||
, Html.span [ Attr.class "host" ] [ Html.text <| " (" ++ story.domain ++ ")" ]
|
||||
, domainView story.domain
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
[ Html.a
|
||||
[-- TODO decode into custom type here? --Attr.href ("/item/" ++ story.id)
|
||||
]
|
||||
[]
|
||||
( Nothing, _ ) ->
|
||||
[ Route.Stories__Id_ { id = String.fromInt story.id }
|
||||
|> Route.link
|
||||
[-- TODO decode into custom type here? --Attr.href ("/item/" ++ story.id)
|
||||
]
|
||||
[ Html.text story.title ]
|
||||
]
|
||||
|
||||
_ ->
|
||||
[ Html.text story.title ]
|
||||
)
|
||||
, Html.br []
|
||||
[]
|
||||
@ -94,6 +85,20 @@ view story =
|
||||
]
|
||||
|
||||
|
||||
domainView : String -> Html msg
|
||||
domainView domain =
|
||||
Html.span
|
||||
[ Attr.class "host"
|
||||
]
|
||||
[ Html.text <|
|
||||
if String.isEmpty domain then
|
||||
""
|
||||
|
||||
else
|
||||
"(" ++ domain ++ ")"
|
||||
]
|
||||
|
||||
|
||||
decoder : Decoder Story
|
||||
decoder =
|
||||
Json.Decode.succeed Story
|
||||
|
Loading…
Reference in New Issue
Block a user