vienalatina/themes/vienalatina/layouts/partials/posts-ordered.html
Claude 751d452556
Fijar: moderators choose what gets read first
Half of this already existed and nothing said so. `threads.pinned` has
been in the schema since the board shipped, with an index on it and a
toggle route, but it was @admin_required, reachable only from inside a
thread, and Inicio ignored it.

Who. Moderators and above, on both halves. Curating what the public
reads is the whole of a moderator's job, and content.py has said so
since the queue was built. Locking a thread rides the same route and is
still an admin's: it stops named people saying anything more to each
other, which is power over people rather than over content, and this
codebase keeps those apart everywhere else.

What is stored. A moment, not a flag — several posts can be pinned and
the newest pin goes first, so the value is the order. `pinned:
'2026-10-13T12:00:00'` in a post's own frontmatter, written only when
true; `threads.pinned_at` beside the flag the wall already had, cleared
on unpinning so that pinning again puts it where a new pin belongs. One
key carrying both means `{{ if .Params.pinned }}` still reads as a
yes/no and nothing has to be kept in step with anything.

translate.py needs nothing: it copies the whole frontmatter and rewrites
only TRANSLATED_KEYS, so a pinned post is pinned in German too. Asserted
against the real list rather than assumed.

Two ways to pin a public post — the switch beside Publicar, and one
press in the Contenido list, because deciding what the site leads with
means looking at the list rather than opening each post to find out what
is in it. Both commit; the file is the record.

Migration 10 adds the columns and recreates the wall's index, which now
names pinned_at. `CREATE INDEX IF NOT EXISTS` leaves an existing index
exactly as it is, so without that a running server keeps the old
definition forever while a fresh install gets the new one. Nothing
breaks either way, which is the problem.

Checked rather than assumed: built with Hugo 0.135.0 and the pipeline's
flags, two pinned posts come out above a newer unpinned one and in
pin order rather than post order, with the pill on the cards and on the
article. And the wall rendered at 390px, where the pinned thread leads
and nothing overflows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-13 18:24:32 +00:00

32 lines
1.7 KiB
HTML

{{/*
The order every list of posts on this site is in, in one place.
Call it with the pages and range over what comes back:
{{ range first 20 (partial "posts-ordered.html" (where site.RegularPages "Section" "post")) }}
{{ range partial "posts-ordered.html" .Pages }}
Four lists used to range over the pages with no sort at all and lean on
Hugo's default, which is weight, then date, then linktitle, then filepath.
That is fine until two posts share a date — and until this phase the editor
wrote `date: 2026-07-31` with no clock, so every post published on one day
was identical in it and Hugo fell through to the title. A day came out
alphabetised, permanently, because nothing about the files changed on a
rebuild. The editor stamps the time now (apps/board/content.py, `stamp`),
and this is the other half: the order is stated rather than inherited, so a
weight somebody adds by hand cannot quietly reorder the home page.
`first N` applied to the result slices something already ordered. Applied
to the input it would slice first and sort afterwards, which is how a
pinned post falls off the end of its own list.
The pinned ones go on top, newest pin first. `pinned` holds the moment it
was pinned rather than `true`, so one key is both the flag and the order —
there is no second field to keep in step with the first. Two sorts appended
rather than one multi-key sort, so this does not depend on Hugo's sort being
stable.
*/}}
{{ $pinned := where . "Params.pinned" "!=" nil }}
{{ $rest := where . "Params.pinned" nil }}
{{ return (append (sort $rest "Date" "desc") (sort $pinned "Params.pinned" "desc")) }}