Skip to content

Instantly share code, notes, and snippets.

@wangrongding
Forked from mbostock/index.html
Created August 9, 2021 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangrongding/3c1a20e062a47f8278f7e3e5dfc0b3e6 to your computer and use it in GitHub Desktop.
Save wangrongding/3c1a20e062a47f8278f7e3e5dfc0b3e6 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<p id="greeting"></p>
<script type="module">
import {Runtime, Inspector, Library} from "https://unpkg.com/@observablehq/notebook-runtime?module";
import notebook from "https://api.observablehq.com/d/6c9b7fd62ca784c0.js";
// Rewrite the notebook to redefine the “subject” cell in the main module.
const override = {
id: notebook.id,
modules: notebook.modules.map(module => {
if (module.id !== notebook.id) return module;
return {
id: module.id,
variables: module.variables.map(variable => {
if (variable.name !== "subject") return variable;
return {
name: variable.name,
inputs: [],
value: () => "Fred"
};
})
};
})
};
Runtime.load(override, new Library, cell => {
if (cell.name === "greeting") {
return new Inspector(document.querySelector("#greeting"));
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment