I have created a HTML file that imports a cell from my notebook following a pattern to call in specific cells that I believe I picked up from @fil somewhere along the way:
for (let i in renders)
renders[i] = document.querySelector(renders[i]);
This patterns works well when I view the HTML page locally on my computer and reference the notebook and runtime .js files from Observable, like this:
<script type="module">
import {Inspector, Runtime} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook from "https://api.observablehq.com/d/9aef18a2b092b886.js";
const renders = {
"map": "#output",
};
for (let i in renders)
renders[i] = document.querySelector(renders[i]);
Runtime.load(notebook, (variable) => {
if (renders[variable.name])
return new Inspector(renders[variable.name]);
});
</script>
After downloading the tarball code and uploading it to GitHub, I want to change the code to reference the local copy of the notebook .js file, like this:
import notebook from "./9aef18a2b092b886@429.js";
But doing so returns a console error:
Uncaught TypeError: r is not iterable
at Function.value (runtime.js:2)
at index_mod.html:28
I note that the approach I am using for calling in multiple cells doesn’t work when I add ?v=3
to the end of my notebook js code when pointing to the observable api, which leads me to expect that the code is only good for older versions of the runtime. Other forum discussions (referenced below) further lead me to believe this might have to do with changes to the runtime. Is that the case?
And what is the new pattern for calling in several specific cells? Would I just repeat this code block from Jeremy’s primer on embedding:
new Runtime().module(notebook, name => {
if (name === "chart") {
return new Inspector(document.querySelector("#chart"));
}
});
… Or is there a way that we can still, as before, define a list of target cells without repeating the code block several times?
Thanks in advance for your help and guidance!
Related reading: