Repository navigation
Expand file tree
/
Copy pathpreview.html
More file actions
32 lines (32 loc) · 1.42 KB
/
Copy pathpreview.html
File metadata and controls
32 lines (32 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow, noarchive">
<meta name="googlebot" content="noindex, nofollow, noarchive">
<title>tzrender Preview</title>
<style>html,body{margin:0;min-height:100%;background:#f4f2f9;font:14px system-ui,sans-serif}body{display:grid;place-items:center;color:#625d70}.preview-error{max-width:34rem;padding:2rem;text-align:center}code{padding:.15rem .3rem;border-radius:4px;background:#e9e5f2}</style>
</head>
<body>
<main class="preview-error" id="previewError" hidden></main>
<script>
(() => {
const params = new URLSearchParams(location.search);
const token = params.get('token');
const key = token && /^[a-z0-9-]+$/i.test(token) ? `tzrender-preview-${token}` : '';
let payload;
try { payload = key ? JSON.parse(sessionStorage.getItem(key) || 'null') : null; } catch { payload = null; }
if (!payload || typeof payload.srcdoc !== 'string') {
const error = document.getElementById('previewError');
error.hidden = false;
error.innerHTML = '<h1>Preview not found</h1><p>Return to the editor and open the Preview again.</p>';
return;
}
document.open('text/html', 'replace');
document.write(`<!doctype html>${payload.srcdoc}`);
document.close();
})();
</script>
</body>
</html>