Closed trieloff closed 3 years ago
I don't like that the contents of the embed.js
is dictated by helix-static
, nor that helix-pipeline
injects HTML.
I would:
embed.js
from helix-pages
, giving the author the possibility to overwrite in his projectpre.js
/ htl
of helix-pages
I can understand the desire to override embed.js
and we can add this ability to helix-static
, too.
What speaks against adding the ESI to the pipeline?
I can understand the desire to override
embed.js
and we can add this ability tohelix-static
, too.
but if it's served from /scripts/embed.js
it's automatically served from the correct place.
What speaks against adding the ESI to the pipeline?
people might have an opinion on the exact way how and when the script is loaded.
- [ ] make a request to
/_hlx_embed/${a.href}
and retrieve a JSON metadata object
better: make a request to /_hlx_embed?src=${a.href}
and retrieve a JSON metadata object
:-)
Basically in other words: if we just removed all the embed stuff from the pipeline (except adding <a href="" class="helix-embed">
), then it can be easily handled in helix-pages today and no changes to helix-static are needed.
Closing. We probably don't need this.
The current system of server-side embeds has some distinct advantages for authors and developers:
but it also comes with marked disadvantages, namely
lazy
) and thus@davidnuescheler and @MarquiseRosier have been experimenting with client-side embeds, with promising results, but this approach has two shortcomings:
The following is a proposal for a unified approach that combines the best of both worlds:
helix-embed
to honor theAccept: application/json
header and return the raw metadata object from unfurl/iframely without a transformation to HTMLhelix-static
to respond to the/_hlx_embed/embed.js
URL and serve an `embed.js' script to run in the browser that will<a href="" class="helix-embed">
(or similar)/_hlx_embed/${a.href}
and retrieve a JSON metadata object<a href="" class="helix-embed">
with the DOM nodehelix-pipeline
to replace externalembed
nodes in the MDAST with<a href="" class="helix-embed">
in HTMLhelix-pipeline
to add an<esi:include src="/_hlx_embed/embed.js.esi">
at the bottom of each HTML document ifembed
nodes have been in the MDASThelix-static
to serve/_hlx_embed/embed.js.esi
with a<script src="/_hlx_embed/embed.js?version=${sha}">
responseAs a result, authors will add embeds as before, and when requesting a page with an embed, following things will happen
<a href="" class="helix-embed">
<esi:include src="/_hlx_embed/embed.js.esi">
at the bottom of the page<script src="/_hlx_embed/embed.js?version=${sha}">
/_hlx_embed/embed.js?version=${sha}
will be loaded by the browser and cached a long time<a href="" class="helix-embed">
and replace the link with an appropriate embed