Skip to content

Commit 086c7e1

Browse files
committed
v3.0.3
1 parent efeede7 commit 086c7e1

File tree

6 files changed

+96
-4
lines changed

6 files changed

+96
-4
lines changed

.changes/v3.0.3.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## v3.0.3 - 2025-10-02
2+
### Changed
3+
* PDF preview now under `<object>` tags with fallback

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
66
and is generated by [Changie](https://github.com/miniscruff/changie).
77

88

9+
## v3.0.3 - 2025-10-02
10+
### Changed
11+
* PDF preview now under `<object>` tags with fallback
12+
913
## v3.0.2 - 2025-10-01
1014
### Changed
1115
* README updated to reflect changes to GitHub actions

content/notes/posts/typst-env-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: "Typst Environment Management and Quick Start"
33
date: 2025-09-29T11:11:08+10:00
44
lastmod: 2025-09-29T11:11:08+10:00
5-
description: "Creating Typst workspace on Linux"
5+
description: "Creating a Typst workspace using cargo and exploring basic funtionality"
66
categories: ["technical-notes"]
77
tags: ["typst", "environment", "academic-writing"]
88
draft: false
99
---
1010

11-
_I have only started using Typst in my toolchain, traditionally I use LaTeX for academic writing. Currently, this note serves as a "quick start" and where Typst fits in my documentation workflow._
11+
_I have only started using Typst, traditionally I use LaTeX for academic writing. Currently, this note serves as a "quick start" and where Typst fits in my documentation workflow._
1212

1313
## Documentation Hierarchy
1414

@@ -60,7 +60,7 @@ From here you can use VSCode as the editor, I am using the [tinymist plugin](htt
6060

6161
To official typst app is [online only](https://typst.app/pricing/).
6262

63-
## Basics
63+
# Typst basics
6464

6565
_I am setting all the typst output with page width 10cm and diffent heights to display nicely within this page._
6666

layouts/_default/_markup/render-codeblock-typst.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
{{ if fileExists (printf "static%s" $pngPath) }}
1111
<img src="{{ $pngPath }}" alt="Typst output" loading="lazy">
1212
{{ else if fileExists (printf "static%s" $pdfPath) }}
13-
<embed src="{{ $pdfPath }}" type="application/pdf" width="100%" height="800px" />
13+
<object data="{{ $pdfPath }}" type="application/pdf" width="100%" height="800px">
14+
<div class="pdf-fallback">
15+
<p>PDF preview unavailable on this device.</p>
16+
<a href="{{ $pdfPath }}" class="pdf-download-btn" download aria-label="Download PDF document">
17+
📄 Download PDF
18+
</a>
19+
</div>
20+
</object>
1421
{{ end }}
1522
<div class="typst-placeholder">
1623
<pre tabindex="0"><code class="language-typst" data-lang="typst">{{- .Inner -}}</code></pre>

mobile-pdf.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.

static/css/typst-render.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,50 @@
127127
display: none;
128128
}
129129

130+
/* PDF fallback for browsers that can't embed PDFs */
131+
.pdf-fallback {
132+
text-align: center;
133+
padding: 4rem 2rem;
134+
color: #cdd6f4;
135+
background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
136+
border-radius: 8px;
137+
min-height: 400px;
138+
display: flex;
139+
flex-direction: column;
140+
align-items: center;
141+
justify-content: center;
142+
}
143+
144+
.pdf-fallback p {
145+
font-size: 1rem;
146+
margin-bottom: 1.5rem;
147+
color: #bac2de;
148+
}
149+
150+
.pdf-download-btn {
151+
display: inline-block;
152+
padding: 0.75rem 2rem;
153+
background: #89b4fa;
154+
color: #1e1e2e;
155+
text-decoration: none;
156+
border-radius: 8px;
157+
font-weight: 600;
158+
font-size: 1rem;
159+
transition: all 0.2s ease;
160+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
161+
}
162+
163+
.pdf-download-btn:hover {
164+
background: #74c7ec;
165+
transform: translateY(-2px);
166+
box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.4);
167+
}
168+
169+
.pdf-download-btn:active {
170+
transform: translateY(0);
171+
box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.3);
172+
}
173+
130174
/* Mobile responsive design */
131175
@media (max-width: 768px) {
132176
.typst-container.side-by-side {

0 commit comments

Comments
 (0)