mirror of
https://github.com/andwati/andwati.com.git
synced 2026-11-16 22:05:13 +00:00
Migrate templates to Zola 0.23 / Tera v2
bin/update-zola always installs the latest release, which as of
v0.23.0 rewrote the template engine to Tera v2. That broke the whole
site: removed filters (slice, concat, escape), test calls now require
named args, shortcodes are gone in favor of Tera components, and
content itself is now Tera-templated before markdown runs.
- slice(end=n) -> native [:n] slicing; concat(with=x) -> spread [...arr, x]
- escape -> escape_html; starting_with/containing -> named `pat` arg
- get_taxonomy_url `name` -> `term` (old name is deprecated)
- %+ date format no longer recognized; replaced with explicit RFC3339 pattern
- shortcodes (note/tip/warning/danger/youtube) rewritten as components;
content call sites updated to component invocation syntax
- {% include %} no longer inherits for-loop-local variables (only ambient
page/section context) - post-card.html converted to a component that
takes page/index explicitly instead of relying on implicit `page`/`loop`
- two content code blocks with literal Jinja-style {{ }} syntax (Netlify
CMS config, a Flask template snippet) wrapped in {% raw %} so Tera
doesn't try to render them, since content is now templated too
- fixed a real content corruption bug along the way: the youtube
shortcode's multi-line <iframe> tag had a conditional that could
collapse to a whitespace-only line, which prematurely closed the
HTML block under CommonMark rules and got the rest of the tag
syntax-highlighted as code instead of rendered
Verified with a clean `zola build` and `zola serve` on v0.23.1, plus a
spot-check of the rendered HTML for both callouts and the video embed.
`zola check` only reports pre-existing external link rot, unrelated to
this change.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{% component danger(title = "") %}
|
||||
<aside class="callout callout-danger">
|
||||
<div class="callout-header">
|
||||
<svg class="callout-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"></polygon><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>
|
||||
@@ -7,3 +8,4 @@
|
||||
{{ body | markdown | safe }}
|
||||
</div>
|
||||
</aside>
|
||||
{% endcomponent danger %}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% component note(title = "") %}
|
||||
<aside class="callout callout-note">
|
||||
<div class="callout-header">
|
||||
<svg class="callout-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>
|
||||
@@ -7,3 +8,4 @@
|
||||
{{ body | markdown | safe }}
|
||||
</div>
|
||||
</aside>
|
||||
{% endcomponent note %}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% component tip(title = "") %}
|
||||
<aside class="callout callout-tip">
|
||||
<div class="callout-header">
|
||||
<svg class="callout-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M12 8v4"></path><path d="M12 16h.01"></path></svg>
|
||||
@@ -7,3 +8,4 @@
|
||||
{{ body | markdown | safe }}
|
||||
</div>
|
||||
</aside>
|
||||
{% endcomponent tip %}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% component warning(title = "") %}
|
||||
<aside class="callout callout-warning">
|
||||
<div class="callout-header">
|
||||
<svg class="callout-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>
|
||||
@@ -7,3 +8,4 @@
|
||||
{{ body | markdown | safe }}
|
||||
</div>
|
||||
</aside>
|
||||
{% endcomponent warning %}
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
<div class="youtube-wrapper">
|
||||
<iframe
|
||||
src="https://www.youtube-nocookie.com/embed/{{ id }}{% if autoplay %}?autoplay=1{% endif %}"
|
||||
{% if title %}title="{{ title }}"{% endif %}
|
||||
loading="lazy"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
{% component youtube(id: string, page, config, title = "", autoplay = false) %}
|
||||
<div class="youtube-wrapper"><iframe src="https://www.youtube-nocookie.com/embed/{{ id }}{% if autoplay %}?autoplay=1{% endif %}"{% if title %} title="{{ title }}"{% endif %} loading="lazy" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>
|
||||
<!-- SEO: VideoObject JSON-LD (confirms this page hosts the embedded video) -->
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "VideoObject",
|
||||
"name": {{ title | default(value=page.title) | json_encode | safe }},
|
||||
"name": {% if title %}{{ title | json_encode | safe }}{% else %}{{ page.title | json_encode | safe }}{% endif %},
|
||||
"description": {{ page.description | default(value=config.description) | json_encode | safe }},
|
||||
"thumbnailUrl": "https://i.ytimg.com/vi/{{ id | safe }}/sddefault.jpg"
|
||||
{% if page.date %},"uploadDate": "{{ page.date | date(format="%+") }}"{% endif %},
|
||||
{% if page.date %},"uploadDate": "{{ page.date | date(format="%Y-%m-%dT%H:%M:%S%:z") }}"{% endif %},
|
||||
"embedUrl": "https://www.youtube-nocookie.com/embed/{{ id | safe }}",
|
||||
"contentUrl": "https://www.youtube.com/watch?v={{ id | safe }}"
|
||||
}
|
||||
</script>
|
||||
{% endcomponent youtube %}
|
||||
|
||||
Reference in New Issue
Block a user