Skip to content

Commit f5c764e

Browse files
Simplify org-hugo handling of static, move to assets for optimization
1 parent 4061e39 commit f5c764e

14 files changed

+48
-51
lines changed

.dir-locals.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
((org-mode
22
. ((eval . (org-hugo-auto-export-mode 1))
33
(org-hugo-base-dir . ".")
4-
(org-hugo-default-static-subdirectory-for-externals . "images"))))
4+
(org-hugo-external-file-extensions-allowed-for-copying . nil))))

Content.org

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ then dispatched to the appropriate override at runtime. Under the hood,
12571257
a virtual table (~vtable~) is created /for each class/, and a pointer
12581258
(~vptr~) to the ~vtable~ is added /to each instance/.
12591259

1260-
#+begin_src plantuml :file diagram.png
1260+
#+begin_src plantuml :file ./assets/images/diagram.png
12611261
@startuml
12621262

12631263
hide empty members
@@ -1307,7 +1307,7 @@ a virtual table (~vtable~) is created /for each class/, and a pointer
13071307

13081308
#+caption: *Virtual dispatch diagram.* The method ~foo~ is declared virtual in ~Base~ and overridden in ~Derived~. Both classes get a ~vtable~, and each object gets a ~vptr~ pointing to the corresponding ~vtable~.
13091309
#+RESULTS:
1310-
[[file:diagram.png]]
1310+
[[file:./assets/images/diagram.png]]
13111311

13121312
On a virtual call, the compiler loads the ~vptr~, selects the right slot
13131313
in the ~vtable~, and performs an indirect call through that function

assets/images/diagram.png

2 Bytes
Loading

content/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ low-latency, high-performance systems. I'm a strong advocate of free
1616

1717
Find me on [GitHub](https://github.com/david-alvarez-rosa/), [GitLab](https://gitlab.com/david-alvarez-rosa), and [LinkedIn](https://linkedin.com/in/david-alvarez-rosa).
1818

19-
[^fn:1]: ![](/images/home-illustration.png)
19+
[^fn:1]: ![](./assets/images/home-illustration.png)

content/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Catalan --- Intermediate
130130
You can reach me at david@alvarezrosa.com (preferred) or +34 647 13
131131
39 30.
132132

133-
[^fn:1]: ![](/images/portrait.png) **That's me!** March 2022.
133+
[^fn:1]: ![](./assets/images/portrait.png) **That's me!** March 2022.
134134
[^fn:2]: Jul 2024--Present<br />
135135
Dublin, Ireland
136136
[^fn:3]: Mar 2022--Aug 2024<br />

content/posts/devirtualization-and-static-polymorphism.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ then dispatched to the appropriate override at runtime. Under the hood,
2525
a virtual table (`vtable`) is created _for each class_, and a pointer
2626
(`vptr`) to the `vtable` is added _to each instance_.
2727

28-
{{< figure src="/images/diagram.png" caption="<span class=\"figure-number\">Figure 1: </span>**Virtual dispatch diagram.** The method `foo` is declared virtual in `Base` and overridden in `Derived`. Both classes get a `vtable`, and each object gets a `vptr` pointing to the corresponding `vtable`." >}}
28+
{{< figure src="./assets/images/diagram.png" caption="<span class=\"figure-number\">Figure 1: </span>**Virtual dispatch diagram.** The method `foo` is declared virtual in `Base` and overridden in `Derived`. Both classes get a `vtable`, and each object gets a `vptr` pointing to the corresponding `vtable`." >}}
2929

3030
On a virtual call, the compiler loads the `vptr`, selects the right slot
3131
in the `vtable`, and performs an indirect call through that function

content/posts/optimizing-a-lock-free-ring-buffer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ minimize scheduling noise.
274274

275275
Long live lock-free and wait-free data structures!
276276

277-
[^fn:1]: ![](/images/ringbuffer.jpg) **Ring buffer with 32 slots.** The
277+
[^fn:1]: ![](./assets/images/ringbuffer.jpg) **Ring buffer with 32 slots.** The
278278
producer has filled 15 of them, indicated by blue. The consumer is
279279
behind the producer, reading data from the slots, freeing them as it
280280
does so. A free slot is indicated by orange.

layouts/partials/img.html

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
1-
{{- $src := .src -}}
1+
{{ $src := .src }}
22

3-
{{- /* Derive alt text from filename: strip path and extension, replace hyphens with spaces */ -}}
4-
{{- $alt := path.BaseName $src | replaceRE `-` " " | strings.FirstUpper -}}
3+
{{ $alt := path.BaseName $src | replaceRE `-` " " | strings.FirstUpper }}
4+
{{ $src := strings.TrimPrefix "./assets/" .src }}
5+
{{ $img := resources.Get $src }}
56

6-
{{- /* Strip leading slash to get asset path */ -}}
7-
{{- $path := strings.TrimPrefix "/" $src -}}
8-
{{- $img := resources.Get $path -}}
7+
{{ if $img }}
8+
{{ $widths := slice 480 768 1024 1536 }}
9+
{{ $origWidth := $img.Width }}
10+
{{ $origHeight := $img.Height }}
911

10-
{{- if $img -}}
11-
{{- $widths := slice 480 768 1024 1536 -}}
12-
{{- $origWidth := $img.Width -}}
13-
{{- $origHeight := $img.Height -}}
12+
{{ $webpSrcset := slice }}
13+
{{ $origSrcset := slice }}
14+
{{ $hasOrigWidth := false }}
15+
{{ range $widths }}
16+
{{ if le . $origWidth }}
17+
{{ if eq . $origWidth }}
18+
{{ $hasOrigWidth = true }}
19+
{{ end }}
20+
{{ $resized := $img.Resize (printf "%dx webp" .) }}
21+
{{ $webpSrcset = $webpSrcset | append (printf "%s %dw" $resized.RelPermalink .) }}
22+
{{ $resizedOrig := $img.Resize (printf "%dx" .) }}
23+
{{ $origSrcset = $origSrcset | append (printf "%s %dw" $resizedOrig.RelPermalink .) }}
24+
{{ end }}
25+
{{ end }}
1426

15-
{{- $webpSrcset := slice -}}
16-
{{- $origSrcset := slice -}}
17-
{{- $hasOrigWidth := false -}}
18-
{{- range $widths -}}
19-
{{- if le . $origWidth -}}
20-
{{- if eq . $origWidth -}}
21-
{{- $hasOrigWidth = true -}}
22-
{{- end -}}
23-
{{- $resized := $img.Resize (printf "%dx webp" .) -}}
24-
{{- $webpSrcset = $webpSrcset | append (printf "%s %dw" $resized.RelPermalink .) -}}
25-
{{- $resizedOrig := $img.Resize (printf "%dx" .) -}}
26-
{{- $origSrcset = $origSrcset | append (printf "%s %dw" $resizedOrig.RelPermalink .) -}}
27-
{{- end -}}
28-
{{- end -}}
29-
30-
{{- if not $hasOrigWidth -}}
31-
{{- $webpFull := $img.Process "webp" -}}
32-
{{- $webpSrcset = $webpSrcset | append (printf "%s %dw" $webpFull.RelPermalink $origWidth) -}}
33-
{{- $origSrcset = $origSrcset | append (printf "%s %dw" $img.RelPermalink $origWidth) -}}
34-
{{- end -}}
27+
{{ if not $hasOrigWidth }}
28+
{{ $webpFull := $img.Process "webp" }}
29+
{{ $webpSrcset = $webpSrcset | append (printf "%s %dw" $webpFull.RelPermalink $origWidth) }}
30+
{{ $origSrcset = $origSrcset | append (printf "%s %dw" $img.RelPermalink $origWidth) }}
31+
{{ end }}
3532

3633
<a href="{{ $img.RelPermalink }}">
3734
<picture>
@@ -50,6 +47,6 @@
5047
decoding="async">
5148
</picture>
5249
</a>
53-
{{- else -}}
50+
{{ else }}
5451
<a href="{{ $src }}"><img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" decoding="async"></a>
55-
{{- end -}}
52+
{{ end }}
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)