Let a blog post be downloaded as a PDF

Download PDF beside the byline opens the browser's print dialog (Save
as PDF) with a print layout: the site's header, footer and notices
hidden, the contents column dropped, the light palette whatever the
screen shows, and at the bottom the post's link and a QR code of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 15:34:43 -05:00
parent c03914a210
commit 5dceeb5860
4 changed files with 61 additions and 7 deletions

View file

@ -175,7 +175,7 @@ export default function Layout() {
{/* ── NAV ─────────────────────────────────────────────── */}
<header
ref={headerRef}
className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md"
className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md print:hidden"
inert={mobileMenuOpen}
>
@ -273,7 +273,7 @@ export default function Layout() {
</header>
{/* Keeps page content clear of the fixed header */}
<div aria-hidden style={{ height: headerHeight }} />
<div aria-hidden className="print:hidden" style={{ height: headerHeight }} />
{/* Page content */}
<main id="main" tabIndex={-1} className="outline-none" inert={mobileMenuOpen}>
@ -283,7 +283,7 @@ export default function Layout() {
</main>
{/*Site Footer applied to every page*/}
<div inert={mobileMenuOpen}>
<div inert={mobileMenuOpen} className="print:hidden">
<Footer />
<PrivacyNotice />
</div>

View file

@ -74,7 +74,7 @@ export default function PostContents({ entries }: { entries: ContentsEntry[] })
const lit = useLit(entries)
return (
<>
<details className="rounded-2xl border border-brand/20 bg-tint-soft p-4 lg:hidden">
<details className="rounded-2xl border border-brand/20 bg-tint-soft p-4 lg:hidden print:hidden">
<summary className="cursor-pointer font-semibold text-ink">On this page</summary>
<div className="mt-3">
<List entries={entries} lit={lit} />
@ -82,7 +82,7 @@ export default function PostContents({ entries }: { entries: ContentsEntry[] })
</details>
<nav
aria-label="On this page"
className="sticky hidden self-start lg:block"
className="sticky hidden self-start lg:block print:hidden"
style={{ top: 'calc(var(--header-h, 5rem) + 1.5rem)' }}
>
<p className="mb-2 px-3 text-sm font-semibold text-ink">On this page</p>