fix: billeder i udkast og preview uden sitemap-link

Zola gør relative billedstier absolutte, så omskrivningen til webp skal matche
den form. Ikke-konverterbare billeder får en rod-relativ sti, som preview kan flytte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Asger Geel Weirsøe
2026-11-01 16:47:08 +01:00
co-authored by Claude Opus 5.5
parent e58a11c2b4
commit aeb7c88949
2 changed files with 7 additions and 2 deletions
+2
View File
@@ -77,7 +77,9 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
{%- if not preview %}
<link rel="sitemap" href="/sitemap-index.xml" />
{%- endif %}
<link rel="alternate" type="application/rss+xml" title="{{ config.title }}" href="/rss.xml" />
<link rel="me" href="https://mastodon.social/@asgerweirsoee" />
<link rel="stylesheet" href="{{ get_url(path="css/site.css", cachebust=true) | replace(from=config.base_url, to="") | safe }}" />
+5 -2
View File
@@ -24,10 +24,13 @@
{#- Billeder i bundlen serveres som webp; markdown bruger bare ![tekst](fil.png). -#}
{%- set indhold = page.content %}
{%- for a in page.assets %}
{%- if a is ending_with(pat=".png") or a is ending_with(pat=".jpg") or a is ending_with(pat=".jpeg") or a is ending_with(pat=".webp") or a is ending_with(pat=".avif") %}
{%- set fil = a | split(pat="/") | last %}
{%- set fra = 'src="' ~ config.base_url ~ page.path ~ fil ~ '"' %}
{%- if fil is ending_with(pat=".png") or fil is ending_with(pat=".jpg") or fil is ending_with(pat=".jpeg") or fil is ending_with(pat=".webp") %}
{%- set b = resize_image(path="blog/" ~ page.slug ~ "/" ~ fil, width=1200, height=10000, op="fit", format="webp", quality=80) %}
{%- set_global indhold = indhold | replace(from='src="' ~ fil ~ '"', to='src="' ~ (b.url | replace(from=config.base_url, to="")) ~ '" width="' ~ b.width ~ '" height="' ~ b.height ~ '" loading="lazy" decoding="async"') %}
{%- set_global indhold = indhold | replace(from=fra, to='src="' ~ (b.url | replace(from=config.base_url, to="")) ~ '" width="' ~ b.width ~ '" height="' ~ b.height ~ '" loading="lazy" decoding="async"') %}
{%- else %}
{%- set_global indhold = indhold | replace(from=fra, to='src="' ~ page.path ~ fil ~ '"') %}
{%- endif %}
{%- endfor %}
<div class="prose mt-8">{{ indhold | safe }}</div>