You can create your own Elm types to represent your documents using the following components.
StructuredText can be rendered to HTML using structuredTextAsHtml.
An element of StructuredText.
A collection of image views.
Properties for a single image view.
Dimensions of an image view.
Embed elements.
Links to other documents or to the web.
A reference to a Prismic document.
Decode a Text field.
Decode a StructuredText field.
Decode an Image field.
Decode a Date field.
Decode a Link field.
Render some StructuredText as HTML.
You must supply a LinkResolver to resolve any links in the StructuredText.
If you don't care about this, you can use the defaultLinkResolver.
Render a single block of StructuredText as HTML.
A LinkResolver simply converts a Prismic DocumentReference to a list of
Html.Attributes. structuredTextAsHtml and friends add these attributes to
links in the text.
For example, you can use this to add onClick handlers to links:
type Msg
= NavigateTo DocumentReference
myLinkResolver : LinkResolver Msg
myLinkResolver docRef =
[ Html.Attributes.href ""
, Html.Events.onClick (NavigateTo docRef)
]
view : StructuredText -> Html Msg
view myStructuredText =
structuredTextAsHtml myLinkResolver myStructuredTextYour update function would handle the NavigateTo message and perform the
appropriate routing.
Adds a default href attribute to links:
[ href "documents/{doc.id}/{doc.slug}" ]
StructuredText helpersGet the first title out of some StructuredText, if there is one.
Get the first image out of some StructuredText, if there is one.
Get the first paragraph out of some StructuredText, if there is one.
Get the contents of a single StructuredText element as a String.
Get the contents of a some StructuredText as a String.
A field in the
Document.