feat(users/Profpatsch/whatcd-resolver): also link json ld fields
We can cross-reference all of these to schema.org, it should work for most of the fields. Change-Id: I38d8dbc7e964764886ddd156c4148bcf3ee376f3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9744 Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
81b790af1d
commit
7129749968
1 changed files with 8 additions and 8 deletions
|
@ -452,7 +452,7 @@ renderJsonld = \case
|
|||
<dd><a href={obj.id_}>{obj.id_}</a></dd>
|
||||
<dt>Fields</dt>
|
||||
<dd>
|
||||
{obj.previewFields & toDefinitionList renderJsonld}
|
||||
{obj.previewFields & toDefinitionList schemaType renderJsonld}
|
||||
<div>
|
||||
<button
|
||||
hx-get={snippetHref obj.id_}
|
||||
|
@ -471,11 +471,11 @@ renderJsonld = \case
|
|||
|
||||
schemaTypes xs =
|
||||
xs
|
||||
<&> ( \t ->
|
||||
let href :: Text = [fmt|https://schema.org/{t}|] in [hsx|<a href={href} target="_blank">{t}</a>|]
|
||||
)
|
||||
<&> schemaType
|
||||
& List.intersperse ", "
|
||||
& mconcat
|
||||
schemaType t =
|
||||
let href :: Text = [fmt|https://schema.org/{t}|] in [hsx|<a href={href} target="_blank">{t}</a>|]
|
||||
JsonldArray arr ->
|
||||
toOrderedList renderJsonld arr
|
||||
JsonldField f -> mkVal f
|
||||
|
@ -569,7 +569,7 @@ mkVal = \case
|
|||
Json.Object obj ->
|
||||
obj
|
||||
& KeyMap.toMapText
|
||||
& toDefinitionList mkVal
|
||||
& toDefinitionList (Html.toHtml @Text) mkVal
|
||||
|
||||
toOrderedList :: (Foldable t1) => (t2 -> Html) -> t1 t2 -> Html
|
||||
toOrderedList mkValFn arr =
|
||||
|
@ -584,11 +584,11 @@ toUnorderedList mkValFn arr =
|
|||
& Html.ul
|
||||
|
||||
-- | Render a definition list from a Map
|
||||
toDefinitionList :: (t -> Html) -> Map Text t -> Html
|
||||
toDefinitionList mkValFn obj =
|
||||
toDefinitionList :: (Text -> Html) -> (t -> Html) -> Map Text t -> Html
|
||||
toDefinitionList mkKeyFn mkValFn obj =
|
||||
obj
|
||||
& Map.toList
|
||||
& foldMap (\(k, v) -> Html.dt (Html.toHtml @Text k) <> Html.dd (mkValFn v))
|
||||
& foldMap (\(k, v) -> Html.dt (mkKeyFn k) <> Html.dd (mkValFn v))
|
||||
& Html.dl
|
||||
|
||||
-- | Render a table-like structure of json values as an HTML table.
|
||||
|
|
Loading…
Reference in a new issue