Contexture icon indicating copy to clipboard operation
Contexture copied to clipboard

Make Contexture content shareable

Open Nagelfar opened this issue 4 years ago • 3 comments

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.

Nagelfar avatar Jun 30 '20 13:06 Nagelfar

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)

Nagelfar avatar Aug 14 '20 12:08 Nagelfar

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

christophwalcher avatar Aug 17 '20 10:08 christophwalcher

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")

Nagelfar avatar Aug 17 '20 10:08 Nagelfar