Skip to content

Commit ba59a5e

Browse files
authored
explicit html, head, body (#1732)
1 parent e8e590c commit ba59a5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+355
-1
lines changed

src/render.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export async function renderPage(page: MarkdownPage, options: RenderOptions & Re
3636
const toc = mergeToc(data.toc, options.toc);
3737
const {files, resolveFile, resolveImport} = resolvers;
3838
return String(html`<!DOCTYPE html>
39+
<html>
40+
<head>
3941
<meta charset="utf-8">${path === "/404" ? html`\n<base href="${preview ? "/" : base}">` : ""}
4042
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
4143
<meta name="generator" content="Observable Framework v${process.env.npm_package_version}">
@@ -81,13 +83,17 @@ import ${preview || page.code.length ? `{${preview ? "open, " : ""}define} from
8183
${preview ? `\nopen({hash: ${JSON.stringify(resolvers.hash)}, eval: (body) => eval(body)});\n` : ""}${page.code
8284
.map(({node, id, mode}) => `\n${transpileJavaScript(node, {id, path, params, mode, resolveImport, resolveFile})}`)
8385
.join("")}`)}
84-
</script>${sidebar ? html`\n${await renderSidebar(options, resolvers)}` : ""}
86+
</script>
87+
</head>
88+
<body>${sidebar ? html`\n${await renderSidebar(options, resolvers)}` : ""}
8589
<div id="observablehq-center">${renderHeader(page.header, resolvers)}${
8690
toc.show ? html`\n${renderToc(findHeaders(page), toc.label)}` : ""
8791
}
8892
<main id="observablehq-main" class="observablehq${draft ? " observablehq--draft" : ""}">
8993
${html.unsafe(rewriteHtml(page.body, resolvers))}</main>${renderFooter(page.footer, resolvers, options)}
9094
</div>
95+
</body>
96+
</html>
9197
`);
9298
}
9399

test/output/build/404/404.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<base href="/">
46
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
@@ -25,6 +27,8 @@
2527
import "./_observablehq/client.00000001.js";
2628

2729
</script>
30+
</head>
31+
<body>
2832
<div id="observablehq-center">
2933
<aside id="observablehq-toc" data-selector="h1:not(:first-of-type)[id], h2:first-child[id], :not(h1) + h2[id]">
3034
<nav>
@@ -38,3 +42,5 @@ <h1 id="page-not-found" tabindex="-1"><a class="observablehq-header-anchor" href
3842
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
3943
</footer>
4044
</div>
45+
</body>
46+
</html>

test/output/build/archives.posix/tar.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -46,6 +48,8 @@
4648
}});
4749

4850
</script>
51+
</head>
52+
<body>
4953
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
5054
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
5155
<nav id="observablehq-sidebar">
@@ -76,3 +80,5 @@ <h1 id="tar" tabindex="-1"><a class="observablehq-header-anchor" href="#tar">Tar
7680
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
7781
</footer>
7882
</div>
83+
</body>
84+
</html>

test/output/build/archives.posix/zip.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -36,6 +38,8 @@
3638
}});
3739

3840
</script>
41+
</head>
42+
<body>
3943
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
4044
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
4145
<nav id="observablehq-sidebar">
@@ -65,3 +69,5 @@ <h1 id="zip" tabindex="-1"><a class="observablehq-header-anchor" href="#zip">Zip
6569
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
6670
</footer>
6771
</div>
72+
</body>
73+
</html>

test/output/build/archives.win32/tar.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -32,6 +34,8 @@
3234
}});
3335

3436
</script>
37+
</head>
38+
<body>
3539
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
3640
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
3741
<nav id="observablehq-sidebar">
@@ -60,3 +64,5 @@ <h1 id="tar" tabindex="-1"><a class="observablehq-header-anchor" href="#tar">Tar
6064
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
6165
</footer>
6266
</div>
67+
</body>
68+
</html>

test/output/build/archives.win32/zip.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -25,6 +27,8 @@
2527
}});
2628

2729
</script>
30+
</head>
31+
<body>
2832
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
2933
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
3034
<nav id="observablehq-sidebar">
@@ -52,3 +56,5 @@ <h1 id="zip" tabindex="-1"><a class="observablehq-header-anchor" href="#zip">Zip
5256
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
5357
</footer>
5458
</div>
59+
</body>
60+
</html>

test/output/build/config/closed/page.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -16,6 +18,8 @@
1618
import "../_observablehq/client.00000001.js";
1719

1820
</script>
21+
</head>
22+
<body>
1923
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
2024
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
2125
<nav id="observablehq-sidebar">
@@ -50,3 +54,5 @@ <h1 id="a-page" tabindex="-1"><a class="observablehq-header-anchor" href="#a-pag
5054
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
5155
</footer>
5256
</div>
57+
</body>
58+
</html>

test/output/build/config/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -16,6 +18,8 @@
1618
import "./_observablehq/client.00000001.js";
1719

1820
</script>
21+
</head>
22+
<body>
1923
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
2024
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
2125
<nav id="observablehq-sidebar">
@@ -53,3 +57,5 @@ <h1 id="index" tabindex="-1"><a class="observablehq-header-anchor" href="#index"
5357
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
5458
</footer>
5559
</div>
60+
</body>
61+
</html>

test/output/build/config/one.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -16,6 +18,8 @@
1618
import "./_observablehq/client.00000001.js";
1719

1820
</script>
21+
</head>
22+
<body>
1923
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
2024
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
2125
<nav id="observablehq-sidebar">
@@ -49,3 +53,5 @@ <h1 id="one" tabindex="-1"><a class="observablehq-header-anchor" href="#one">One
4953
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
5054
</footer>
5155
</div>
56+
</body>
57+
</html>

test/output/build/config/sub/two.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
<head>
24
<meta charset="utf-8">
35
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
46
<meta name="generator" content="Observable Framework v1.0.0-test">
@@ -16,6 +18,8 @@
1618
import "../_observablehq/client.00000001.js";
1719

1820
</script>
21+
</head>
22+
<body>
1923
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
2024
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
2125
<nav id="observablehq-sidebar">
@@ -49,3 +53,5 @@ <h1 id="two" tabindex="-1"><a class="observablehq-header-anchor" href="#two">Two
4953
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-01-10T16:00:00">Jan 10, 2024</a>.</div>
5054
</footer>
5155
</div>
56+
</body>
57+
</html>

0 commit comments

Comments
 (0)