|
| 1 | +# Mobile Typst PDF Handling |
| 2 | + |
| 3 | +## Analysis |
| 4 | +- The `.render` Typst blocks fall back to `<embed>` when only a PDF exists, which fails on |
| 5 | + iOS/WebKit-based browsers (e.g. Firefox on iPhone) and results in a blank area. |
| 6 | +- Current assets already include the compiled PDF (e.g. `typst-2236670690.pdf`), so a download |
| 7 | + fallback can reuse the same path without new renders. |
| 8 | +- CSS media queries are sufficient for a coarse “mobile” check; no user-agent sniffing or JS is |
| 9 | + required and we stay within Hugo’s static rendering model. |
| 10 | + |
| 11 | +## Plan |
| 12 | +1. Extend `layouts/_default/_markup/render-codeblock-typst.html` so render blocks output two |
| 13 | + wrappers: the existing PDF `<embed>` plus a fallback panel containing a download prompt that |
| 14 | + links to the PDF path. |
| 15 | +2. Adjust `static/css/typst-render.css` to hide the `<embed>` on narrow viewports (e.g. |
| 16 | + `max-width: 768px`) and show the fallback panel instead; keep desktop behaviour unchanged. |
| 17 | +3. Optionally add an accessible hint (e.g. `aria-label`, visually hidden text) so assistive |
| 18 | + technologies know the panel is a download link. |
| 19 | +4. Re-run `bash scripts/render-typst.sh` only if template changes modify hash calculations (not |
| 20 | + expected), then validate on desktop and a WebKit-based mobile browser. |
| 21 | + |
| 22 | +## Potential Issues |
| 23 | +- CSS breakpoint approximates “mobile” and may trigger on narrow desktop windows; ensure the |
| 24 | + download prompt still feels reasonable in that context. |
| 25 | +- If future Typst renders include both PDF and per-page PNGs, we should confirm the fallback logic |
| 26 | + prefers the richer preview when available. |
| 27 | +- Some older browsers may not fully respect the CSS; adding a `<noscript>` block with the download |
| 28 | + link is an extra safeguard if that becomes necessary. |
| 29 | + |
| 30 | +## Other Notes |
| 31 | +- No Hugo front matter or site configuration changes required; the behaviour stays confined to the |
| 32 | + Typst code-block partial and shared stylesheet. |
| 33 | +- Keep the fallback wording neutral (“PDF preview unavailable on mobile – tap to download”) so it |
| 34 | + applies across devices and avoids promising inline rendering. |
0 commit comments