🏠 back to Observable

Handy Embed Code for shared notebooks

The Handy Embed Code Generator no longer seems to work for shared notebooks. For example, here’s a notebook that I shared recently:

If I go to the Handy Embed Code Generator and type in the identifier 2f037ab01d3a1ed2 or include the ‘d’ to get d/2f037ab01d3a1ed2 I get an error. It’s clearly trying and I’m quite sure I’ve done this before but, no more.


To be clear, it just the code generator itself that is broken and only when applied to shared notebooks. It works fine for published notebooks. In addition, the embedding procedure itself works fine. Thus, if you know how to do it, it’s still easy to embed a shared notebook - it’s just not … handy. :slight_smile:

For example, the above link is embedded here.

2 Likes

The notebook fetches the v3 format and parses the frontmatter at the beginning of a notebook source.

Interestingly, the frontmatter is now missing in unpublished notebooks. v1 still has it.

Shameless plug: I have support for both formats in getPinnedSlug():

2 Likes

Here’s a fix that fetches the metadata from v1 instead (compare):

2 Likes

Most excellent - thanks! Might be worth sending it as a suggestion to @jashkenas.

Already done, the compare link is taken from the suggestion. :slight_smile:

1 Like

The comment that Jeremy’s Handy notebook depended on to find the version was recently removed from nonpublic notebooks to reduce the risk of downloaded source accidentally leaking the location of a nonpublic notebook. (Like, if you download it and use it somewhere, as opposed to a direct embed.) We’re workin on easier ways to embed, so this shouldn’t be a problem for long! Good eye.

1 Like

Perhaps you can add back a comment that contains only the version (similar to the frontmatter in v1)?
Or alternatively support a @latest version identifier that will redirect to a specific version? Then the version could be parsed from response.url.

1 Like