vienalatina/themes/vienalatina/layouts/partials/header.html
Claude 8936f296ea
Textos: the words are data now, starting with the navigation
Renaming «Inicio» was six edits — base.html, home.py's section list,
config.yaml three times, an aria-label, and the breadcrumb schema — and
none of them reachable from Gestión. That is the thing Identidad exists
to end for the site's name, and it stopped before it reached the labels.

The mechanism, and the navigation through it. The rest of the ~560
strings follow in later commits; this one is the path proved end to end.

apps/board/strings/*.yaml is the catalogue, shipped in the image through
the Dockerfile's existing COPY. Only the differences are stored, which
is brand.FACTORY's rule and buys the same thing: a wording I improve
later improves for everyone who has not deliberately overridden it.

The `site.` prefix decides everything — one box or three, SQLite or a
commit of data/ui.yaml, this page load or the next pipeline run.

The fallback order is a judgement rather than an accident: an override
for the asked-for language, then the *shipped* word in that language,
then Spanish. Somebody who reworded only the Spanish has said nothing
about German, and showing a German reader Spanish would be reading an
intention into silence. Verified in a real build: with es overridden,
the Spanish menu says «Escritorio» and the German still says «Start».

The screen is generic — it iterates the catalogue, so extracting another
hundred strings costs nothing here. There is no field list in ui.py and
there must never be one.

Two guards are what make a 560-string extraction mechanical rather than
risky: every t("…") used must exist, and every key defined must be used.
A typo renders as nav.incio on a page; an orphan is a box in Gestión
that changes nothing. Both fail the suite instead. I proved all three
guards (including the one holding t.html to the catalogue) by
introducing the bug each describes and watching it go red.

Two things fixed on the way, both found by the extraction rather than
looked for: home.py and base.html held two copies of the same six words,
so a rename would have reached the members area and not the strip on the
public site; and memberbar.js hardcoded two more in a fingerprinted
script, the one surface no setting could ever reach.

No migration — `strings` is a new table, so CREATE TABLE IF NOT EXISTS
makes it, as activity and site arrived. The erase guard caught the new
members(id) reference by itself, which is the mechanism working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-14 12:35:10 +00:00

156 lines
7.4 KiB
HTML

{{/* Ported from theme/header.php — static version: no login/account controls.
No Google Fonts: the font-family stack in main.css falls back to system
sans-serif, keeping the site free of third-party requests (GDPR). */}}
<header class="site-bar">
<div class="site-bar__inner">
<a class="site-bar__brand" href="{{ .Site.Home.Permalink }}" aria-label="{{ partial "t.html" (dict "key" "home" "lang" .Site.Language.Lang) }}">
{{/* The logo uploaded in Gestión → Marca, and the site's name in
letters when there is none. The alt text is the name either way,
so a reader who does not see the picture reads the same thing.
Read through two variables rather than as
`site.Data.brand.logo`, because on a site with no data/brand.yaml
that expression is a field lookup on nil and fails the build —
which is precisely the state every install starts in. */}}
{{ $logo := "" }}{{ $stamp := "0" }}
{{ with site.Data.brand }}{{ $logo = .logo }}{{ $stamp = .stamp }}{{ end }}
{{ with $logo }}
<img class="site-bar__logo" src="{{ . }}?v={{ $stamp }}"
alt="{{ partial "site-name.html" $ }}">
{{ else }}
<span class="site-bar__brand-text">{{ partial "site-name.html" . }}</span>
{{ end }}
</a>
<nav class="site-bar__nav" aria-label="Idioma">
{{/* Desktop only; the mobile copy is at the foot of the menu panel
below. Rendered twice rather than moved, because at 360px the bar
cannot hold a brand, a button, a ☰ and three language letters
without something wrapping — and CSS cannot lift an element out
of the bar and into the panel. */}}
{{ partial "lang-switcher.html" . }}
</nav>
{{/* The way into the members area, as a button rather than a word in the
menu. It is the one link on this site that is not content: somebody
who has an account needs to find the door at a glance, and somebody
who does not should see that there is one. In the bar at every width,
so a phone never has to open a menu to find it. */}}
<a class="site-bar__cta" href="/comunidad/">{{ partial "t.html" (dict "key" "community" "lang" .Site.Language.Lang) }}</a>
{{/* The ☰ itself. A <label> can sit anywhere in the document, so the
checkbox it drives lives below, as a sibling of the menu it opens —
which is what lets one CSS rule show the menu with no script. */}}
<label class="site-bar__hamburger" for="site-menu" aria-hidden="true">
<span class="hamburger-line"></span>
<span class="hamburger-line"></span>
<span class="hamburger-line"></span>
</label>
</div>
{{/* The state of the menu, as a checkbox, immediately before the menu so
that `:checked ~ .site-bar__pages` reaches it.
A checkbox rather than a <details>, which is this project's usual answer
for a menu without a script. It does not work here: on desktop this menu
has to be open and horizontal, and current Chrome hides a closed
<details>'s content with content-visibility on ::details-content, which
a display rule on the child no longer overrides. The trick that made
that work has gone; a checkbox behaves the same in every engine.
Visually hidden but not `hidden`: it keeps its place in the tab order,
right before the menu it controls, and is announced with its own label —
so the menu opens from a keyboard. The ☰ above is aria-hidden because it
would otherwise be read a second time as the same control. */}}
<input id="site-menu" class="site-menu__state" type="checkbox"
aria-label="{{ partial "t.html" (dict "key" "menu" "lang" .Site.Language.Lang) }}">
{{/* The menu is built from the pages themselves, not from a list in
config.yaml. It used to be three names written there, which meant a page
published from the members area never appeared on the site at all — and
that the German and Portuguese menus had to be kept in step by hand.
Built this way, a new page shows up when it is published, with its own
translated title in each language.
Two levels: a page with `parent: <basename>` in its frontmatter hangs
under the page with that basename. The basename is the one translate.py
already uses to pair siblings — `acerca` for acerca.es.md, acerca.de.md
and acerca.pt-br.md — so a parent set once holds in all three languages.
Only Inicio and Comunidad stay in config.yaml, before and after the
pages, which is what the weight split below is reading. */}}
{{ $current := . }}
{{/* A dict per page rather than sorting the pages directly: `weight` is
optional, and sorting on a key half of them do not carry puts the rest
in an order nobody chose. Defaulted here, once. */}}
{{ $pages := slice }}
{{ range where .Site.RegularPages "Section" "page" }}
{{ $base := "" }}
{{ with .File }}{{ $base = .ContentBaseName }}{{ end }}
{{ $pages = $pages | append (dict
"title" .LinkTitle
"url" .RelPermalink
"page" .
"base" $base
"parent" (.Params.parent | default "")
"w" (.Params.weight | default 50)) }}
{{ end }}
{{ $pages = sort $pages "w" }}
<nav class="site-bar__pages" id="site-bar-pages" aria-label="Secciones">
<ul class="page-nav">
{{/* config.yaml still says the entry exists and where it sits —
`weight` decides the side, and a data file cannot override a
menu (see site-name.html). What it is *called* comes through
the table, so «Inicio» can become «Escritorio» without a
commit. Only the home entry has a key; anything else somebody
adds to the menu keeps its own name. */}}
{{ range where .Site.Menus.main "Weight" "<" 5 }}
{{ $label := .Name }}
{{ if eq .Identifier "home" }}{{ $label = partial "t.html" (dict "key" "home" "lang" $.Site.Language.Lang) }}{{ end }}
<li{{ if $current.IsMenuCurrent "main" . }} class="current-menu-item"{{ end }}>
<a href="{{ .URL }}">{{ $label }}</a>
</li>
{{ end }}
{{ range where $pages "parent" "" }}
{{ $children := where $pages "parent" .base }}
{{/* The class names are the ones main.css already styles — ported
from the WordPress theme, dropdown on hover and on focus-within,
inline on a phone, with a ▾ on anything that has children. There
was no reason to invent a second set. */}}
{{ $classes := slice }}
{{ if $children }}{{ $classes = $classes | append "menu-item-has-children" }}{{ end }}
{{ if eq $current.RelPermalink .url }}{{ $classes = $classes | append "current-menu-item" }}{{ end }}
<li{{ with $classes }} class="{{ delimit . " " }}"{{ end }}>
<a href="{{ .url }}">{{ .title }}</a>
{{ with $children }}
{{/* Opens on hover and on focus — CSS only, so it works with a
keyboard and needs no script. */}}
<ul class="sub-menu">
{{ range . }}
<li{{ if eq $current.RelPermalink .url }} class="current-menu-item"{{ end }}>
<a href="{{ .url }}">{{ .title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
{{ range where .Site.Menus.main "Weight" ">=" 5 }}
<li{{ if $current.IsMenuCurrent "main" . }} class="current-menu-item"{{ end }}>
<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{/* The language switcher again, for the phone. The copy in the bar is
hidden below 768px and this one is shown — see the note up there for
why it is rendered twice rather than moved. */}}
<div class="site-bar__pages-lang">
{{ partial "lang-switcher.html" . }}
</div>
</nav>
</header>