1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00
Files
whiskr/internal/preview.html

44 lines
1.0 KiB
HTML
Raw Normal View History

2025-11-04 00:23:29 +01:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="/lib/catppuccin.min.css" rel="stylesheet" />
<link href="/css/preview.css" rel="stylesheet" />
<title>File Preview</title>
<script>
const data = {{ . | json }};
</script>
</head>
<body>
<pre><code></code></pre>
<script src="/lib/highlight.min.js"></script>
<script>
const title = document.querySelector("title"),
body = document.querySelector("code");
title.innerText = data.name;
body.innerHTML = hljs.highlightAuto(data.content).value;
addEventListener("keydown", event => {
if ((event.ctrlKey || event.metaKey) && event.key === "S") {
event.preventDefault();
const el = document.createElement("a");
el.download = data.name;
el.href = `data:text/plain;base64,${btoa(data.content)}`;
el.click();
} else if (event.key === "Escape") {
window.close();
}
});
</script>
</body>
</html>