Contexture
Contexture copied to clipboard
Make Contexture content shareable
Content captured in Contexture should easily be shareable in web based environments. E.g. provide something like Twitter Cards or OpenGraph meta-tags ensure that content can be embedded & read.
Adding meta
-data into head
is hard with Elm. Solutions like elm-pages only work for static generated sites.
A possible solution could be to split up the single Elm-SPA into at least the following parts:
- Domain overview
- Domain detail
- Bounded context detail
Then each of these parts could be pre-rendered with meta-tags on the server. Then including a title
(domain/bounded context title) and description
(domain/bounded context description) on the server is simple, while rendering the remainder of the page client side.
Splitting up the application in these parts should be quite simple.
Alternatively solutions:
- a full fledged serverside rendered process (rendering all of it on demand on the server)
- manipulated head-tag with JavaScript (via Elm-ports), but this relies on the JavaScript execution on embedding the content (which might not be working)
Would JavaScript interop do the trick? create-elm-app example:
elmSpa.ports.urlChange.subscribe(function(title) {
window.requestAnimationFrame(function() {
document.title = title;
document.querySelector(
'meta[name="description"]'
).setAttribute("content", title);
});
});
Blog post https://medium.com/@l.mugnaini/single-page-application-boilerplate-for-elm-160bb5f3eec2
I have no idea if this would work with e.g. Twitter cards or other places were content is embedded, as it relies on executing the whole page with JS.
(The method is mentioned with more detail in the articled I linked to - "Extracting the SEO API from elm-pages")