website/website/reader.html
yourfriendoss b3f45ece0c
All checks were successful
/ build (push) Successful in 25s
fix the shit slightly
2025-10-11 00:20:22 +03:00

158 lines
3.3 KiB
HTML

__TEMPLATE_HEAD__
<style>
:root {
--bg: #fbfbf8;
--text: #1a1a18;
--accent: #165b46;
--muted: #5f635f;
--max-width: 75ch;
--line-height: 1.65;
--serif: Georgia, "Times New Roman", Times, serif;
--mono: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #111312;
--text: #eaeaea;
--accent: #70d7ba;
--muted: #a0a0a0;
}
}
html {
background: var(--bg);
color: var(--text);
font-family: var(--serif);
font-size: clamp(18px, 1.2vw + 14px, 20px);
line-height: var(--line-height);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
scroll-behavior: smooth;
}
body {
margin: 0 auto;
padding: clamp(2rem, 6vh, 4rem) clamp(1rem, 4vw, 3rem);
max-width: var(--max-width);
box-sizing: border-box;
}
header, nav, aside, footer, form, button, input, textarea, select,
img, video, picture, iframe, .sidebar, .widget, .ads {
display: none !important;
}
h1, h2, h3, h4 {
font-weight: 600;
line-height: 1.15;
margin: 0 0 0.8rem 0;
}
h1 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); color: var(--accent); }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); color: var(--muted); }
p {
margin: 0 0 1rem 0;
text-wrap: balance;
}
ul, ol {
margin: 0 0 1rem 1.25rem;
}
pre, code {
font-family: var(--mono);
background: color-mix(in srgb, var(--text) 10%, var(--bg));
color: var(--text);
padding: 0.4rem 0.6rem;
border-radius: 6px;
display: block;
overflow: auto;
white-space: pre-wrap;
font-size: 0.94em;
}
a {
color: var(--accent);
text-decoration: underline;
text-underline-offset: 2px;
}
a:focus-visible {
outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
outline-offset: 3px;
}
body > * {
margin-bottom: 1rem;
}
@media (max-width:600px) {
body {
padding: 1.5rem 1rem;
max-width: 100%;
}
}
@media print {
body {
background: #fff;
color: #000;
font-size: 12pt;
}
a::after {
content: " (" attr(href) ")";
font-size: 90%;
color: #111;
}
}
</style>
</head>
<body>
<script>
(async function() {
const params = new URLSearchParams(location.search);
const id = params.get('md');
if (!id) {
document.body.innerHTML = "<h1>Blog not found</h1><p>No blog id specified.</p>";
return;
}
let meta;
try {
const res = await fetch(`/blogs/${id}.json`);
if (!res.ok) throw new Error("meta not found");
meta = await res.json();
} catch (e) {
document.body.innerHTML = "<h1>Blog not found</h1><p>Metadata for this blog could not be loaded.</p>";
return;
}
let html;
try {
const res = await fetch(`/blogs/${id}.html`);
if (!res.ok) throw new Error("html not found");
html = await res.text();
} catch (e) {
document.body.innerHTML = "<h1>Blog not found</h1><p>Content for this blog could not be loaded.</p>";
return;
}
function formatDate(ts) {
const d = new Date(ts * 1000);
return d.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });
}
document.body.innerHTML = `
<p style="color:var(--muted);font-size:0.98em;margin-top:-0.5rem;margin-bottom:2rem;">
${meta.time ? formatDate(meta.time) : ""}
</p>
${html}
`;
})();
</script>
</body>
</html>