Hi Observable!
I’ve been following along Jeremy’s Downloading and Embedding Notebooks in trying to embed two cells from a simple notebook into an HTML container. I’ve had some past luck w/ embeds, but each time I hacked away till hitting a solution without really understanding what made things work. As I am again encountering issues, I turn to you for insights and guidance.
Here’s the HTML I am trying to use, which is derived from Jeremy’s Breakout example, but replaces his notebook ID and cell names with my own (note too, that @jashkenas 's example is itself returning mutable score could not be resolved
):
Embedded Observable notebookTEST<script type="module"> import {Inspector, Runtime} from "https://unpkg.com/@observablehq/notebook-runtime@1.0.1?module"; import notebook from "https://observablehq.com/d/87de48220ae3faec"; const renders = { "viewof value": "#labels", "output": "#output", }; Runtime.load(notebook, (variable) => { const selector = renders[variable.name]; if (selector) { return new Inspector(document.querySelector(selector)); } else { return true; } }); </script>
… This code, however, doesn’t return anything.
For good measures, I tried adapting the code following Fil’s example (which uses a different version of the runtime):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Embedded Observable notebook</title>
</head>
<body>
<div class="wrapper">
<div class="title">TEST</div>
<div id="labels"></div>
<div id="output"></div>
</div>
<script type="module">
import {Inspector, Runtime} from "https://unpkg.com/@observablehq/notebook-runtime@2?module";
import notebook from "https://observablehq.com/d/87de48220ae3faec";
const renders = {
"viewof value": "#labels",
"output": "#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>
</body>
</html>
… still no dice, with errors like:
Access to script at 'https://observablehq.com/d/87de48220ae3faec.js' from origin 'https://aaronkyle.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
embed-test.html:18 GET https://observablehq.com/d/87de48220ae3faec.js net::ERR_FAILED
Access to script at 'https://observablehq.com/d/87de48220ae3faec.js' from origin 'https://aaronkyle.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
embed-test.html:18 GET https://observablehq.com/d/87de48220ae3faec.js net::ERR_FAILED
Any idea what I might be missing? Seems that these embeds should be easy… but there’s clearly something I haven’t yet figured out.
Thanks in advance for your help!