diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html
new file mode 100644
index 0000000..4b2ed19
--- /dev/null
+++ b/layouts/_default/_markup/render-heading.html
@@ -0,0 +1,9 @@
+{{- /*
+ Heading render hook.
+ Emits with loading="lazy" decoding="async". When the source resolves
+ to a Page Resource, derives a responsive srcset via images.Process/Resize
+ and sets intrinsic width/height to reduce CLS.
+*/ -}}
+{{- $src := .Destination -}}
+{{- $alt := .Text -}}
+{{- $title := .Title -}}
+{{- $isExternal := or (strings.HasPrefix $src "http:") (strings.HasPrefix $src "https:") (strings.HasPrefix $src "//") -}}
+{{- $resource := false -}}
+{{- if and (not $isExternal) .Page -}}
+ {{- with .Page.Resources.GetMatch $src -}}
+ {{- if eq .ResourceType "image" -}}
+ {{- $resource = . -}}
+ {{- end -}}
+ {{- end -}}
+{{- end -}}
+{{- if $resource -}}
+ {{- $orig := $resource -}}
+ {{- $w := $orig.Width -}}
+ {{- $h := $orig.Height -}}
+ {{- $widths := slice 480 768 1200 1600 -}}
+ {{- $srcset := slice -}}
+ {{- range $widths -}}
+ {{- if le . $w -}}
+ {{- $img := $orig.Resize (printf "%dx" .) -}}
+ {{- $srcset = $srcset | append (printf "%s %dw" $img.RelPermalink .) -}}
+ {{- end -}}
+ {{- end -}}
+ {{- $srcset = $srcset | append (printf "%s %dw" $orig.RelPermalink $w) -}}
+
+{{- else -}}
+
+{{- end -}}
diff --git a/layouts/_default/_markup/render-inline.html b/layouts/_default/_markup/render-inline.html
index bf904a2..98c6f6e 100644
--- a/layouts/_default/_markup/render-inline.html
+++ b/layouts/_default/_markup/render-inline.html
@@ -1,8 +1,7 @@
+{{- /*
+ Inline render hook.
+ Trust assumption: inline content is authored markdown (LaTeX math source);
+ safeHTML preserves $...$ delimiters for client-side KaTeX processing.
+*/ -}}
{{- $text := .Text | strings.TrimSpace -}}
-{{- if and (hasPrefix $text "$") (hasSuffix $text "$") (not (hasPrefix $text "$$")) -}}
- {{/* Inline math - output directly without wrapping */}}
- {{ $text | safeHTML }}
-{{- else -}}
- {{/* Regular inline text */}}
- {{ $text | safeHTML }}
-{{- end -}}
+{{ $text | safeHTML }}
diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
index d09802f..39b3abc 100644
--- a/layouts/_default/_markup/render-link.html
+++ b/layouts/_default/_markup/render-link.html
@@ -1,15 +1,16 @@
+{{- /*
+ Link render hook.
+ Hugo's render-link context provides resolved URLs; no manual BaseURL prepend needed.
+*/ -}}
{{- $url := .Destination -}}
{{- $isExternal := or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") -}}
-{{- $fullUrl := $url -}}
-{{- if and (not $isExternal) (strings.HasPrefix $url "/") -}}
- {{- $fullUrl = printf "%s%s" (.Page.Site.BaseURL | strings.TrimSuffix "/") $url -}}
-{{- end -}}
-
-
- {{- with .Text }}{{ . }}{{ end -}}
-
-{{- /* chomp trailing newline */ -}}
+ {{- if $isInternalAbsolute }} data-internal-link="{{ $url }}" class="internal-link"{{ end -}}
+>{{- with .Text }}{{ . | safeHTML }}{{ end -}}
+{{- /*
+ Note: .Text is rendered inline content (may contain emphasis tags etc.);
+ safeHTML preserves those tags.
+*/ -}}
diff --git a/layouts/_default/_markup/render-paragraph.html b/layouts/_default/_markup/render-paragraph.html
index 95d8e0e..fda6721 100644
--- a/layouts/_default/_markup/render-paragraph.html
+++ b/layouts/_default/_markup/render-paragraph.html
@@ -1,11 +1,14 @@
-{{- $content := .Inner | strings.TrimSpace -}}
+{{- /*
+ Paragraph render hook.
+ Trust assumption: math branches emit raw markdown ($$...$$ / $...$) so
+ client-side KaTeX can process it; safeHTML is intentional there.
+ Default branch lets Hugo's auto-escaping handle authored content.
+*/ -}}
+{{- $content := .Text | strings.TrimSpace -}}
{{- if and (hasPrefix $content "$$") (hasSuffix $content "$$") -}}
- {{/* Block math - output directly without
wrapper */}} {{ $content | safeHTML }} {{- else if and (hasPrefix $content "$") (hasSuffix $content "$") (not (strings.Contains $content "\n")) (not (strings.Contains $content " ")) -}} - {{/* Single inline math expression - output directly without
wrapper */}} {{ $content | safeHTML }} {{- else -}} - {{/* All other content including paragraphs with inline math - wrap in
and let KaTeX process */}}
{{ $content }}
{{- end -}} diff --git a/layouts/partials/recent-posts-grid.html b/layouts/partials/recent-posts-grid.html index 72d98d2..b601f9f 100644 --- a/layouts/partials/recent-posts-grid.html +++ b/layouts/partials/recent-posts-grid.html @@ -1,29 +1,29 @@