Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: Update HTML download functionality and fonts (#415)

Myles Scolnick1a9c5347b4bd
diff --git a/frontend/src/core/static/__tests__/__snapshots__/download-html.test.ts.snap b/frontend/src/core/static/__tests__/__snapshots__/download-html.test.ts.snap
index 4f19a4d87b..f2973f2820 100644
--- a/frontend/src/core/static/__tests__/__snapshots__/download-html.test.ts.snap
+++ b/frontend/src/core/static/__tests__/__snapshots__/download-html.test.ts.snap
@@ -1,7 +1,8 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`download-html > should construct html correctly 1`] = `
-"<html>
+"<!DOCTYPE html>
+<html>
<head>
<meta charset=\\"utf-8\\" />
<link
@@ -48,6 +49,13 @@ exports[`download-html > should construct html correctly 1`] = `
resizeObserver.observe(obj.contentWindow.document.body);
}
</script>
+
+ <link rel=\\"preconnect\\" href=\\"https://fonts.googleapis.com\\" />
+ <link rel=\\"preconnect\\" href=\\"https://fonts.gstatic.com\\" crossorigin=\\"\\" />
+ <link
+ href=\\"https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&amp;family=Lora&amp;family=PT+Sans:wght@400;700&amp;display=swap\\"
+ rel=\\"stylesheet\\"
+ />
</head>
<body>
diff --git a/frontend/src/core/static/download-html.ts b/frontend/src/core/static/download-html.ts
index 1086059ce3..f993d09f93 100644
--- a/frontend/src/core/static/download-html.ts
+++ b/frontend/src/core/static/download-html.ts
@@ -174,7 +174,15 @@ export function constructHTML(opts: {
doc.body.append(devScript);
}
- return doc.documentElement.outerHTML;
+ doc.head.innerHTML = `
+ ${doc.head.innerHTML}
+ <link rel="preconnect" href="https://fonts.googleapis.com">
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+ <link href="https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&family=Lora&family=PT+Sans:wght@400;700&display=swap" rel="stylesheet">
+ `.trim();
+
+ // add DOCTYPE back in
+ return `<!DOCTYPE html>\n${doc.documentElement.outerHTML}`;
}
function updateAssetUrl(existingUrl: string, assetBaseUrl: string) {
diff --git a/frontend/src/css/fonts.css b/frontend/src/css/fonts.css
index b42b1064f5..4d14f0aead 100644
--- a/frontend/src/css/fonts.css
+++ b/frontend/src/css/fonts.css
@@ -1,3 +1,6 @@
+/* This must be kept in sync with the fonts used in the static HTML download,
+but instead use the Google Fonts CDN.
+see frontend/src/core/static/download-html.ts */
@font-face {
font-family: Lora;
font-style: normal;