Clean up domain view.

This commit is contained in:
Dillon Kearns 2022-04-11 11:04:55 -07:00
parent 34db38420c
commit 8a3c787906
2 changed files with 28 additions and 28 deletions

View File

@ -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"
]

View File

@ -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