Published
Edited
Jul 22, 2022
1 fork
5 stars
Insert cell
Insert cell
params = ({
title: "Hello!",
description: "An example of a simple custom embedding",
image:
"https://static.observableusercontent.com/files/e317bdba3a086d0dd589c78ebd8f96068b6c2991ff1e90370339bbdbd3bd71f2c446fb16e6542264a9b187e2d8778dcfcf722e91561539c03921aff20b8ce46b",
url:
"https://webcode.run/observablehq.com/@tomlarkworthy/example-custom-embed"
})
Insert cell
webserver = deploy(
"default",
async (req, res, ctx) => {
res.header("cache-control", "public, max-age: 3600, s-maxage: 3600");
res.send(page(params));
},
{
hostNotebook: "@tomlarkworthy/example-custom-embed"
}
)
Insert cell
Insert cell
page = ({
title,
description,
type = "article",
image,
url,
twitter_card = "summary_large_image",
notebook = "@tomlarkworthy/example-custom-embed"
} = {}) => `<!DOCTYPE html>
<meta property="og:title" content="${title}">
<meta property="og:description" content="${description}">
<meta property="og:type" content="${type}" />
<meta property="og:image" content="${image}">
<meta property="og:url" content="${url}">
<meta name="twitter:card" content="${twitter_card}">

<body style="background-color:yellow;">
<div id="display"></div>
<script type="module">
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook from "https://api.observablehq.com/${notebook}.js?v=3";
new Runtime().module(notebook, name => {
if (name === "display") {
return new Inspector(document.querySelector("#display"));
}
});
</script>
<script defer data-domain="example.com" src="https://plausible.io/js/plausible.js"></script>`
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more