Changeset a3e2f17 in Klonkt


Ignore:
Timestamp:
06/17/2026 12:49:19 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1dca23b
Parents:
ee25d45
Message:

Fix: update per-site accent + palette on htmx navigation

The accent colour (style#pcms-site-accent) and palette (html[data-palette])
live in the shell <head>, which is not swapped during htmx nav. As a result
an artist inherited the colours of the previous page (e.g. De Kelderband
got the hub's purple instead of its own green). pcmsNav now sends
accent+palette along; the client updates the accent <style> and
data-palette. Applies to all htmx nav (boost + explicit links).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/render.js

    ree25d45 ra3e2f17  
    113113      // looks "unclickable". Escape any non-ASCII to \uXXXX: the header stays
    114114      // ASCII-safe and remains valid JSON that htmx parses back unchanged.
     115      // Per-site accent + palette zitten in de shell-<head> (style#pcms-site-accent
     116      // + html[data-palette]) en worden NIET mee-geswapt bij htmx-nav. Stuur ze mee
     117      // zodat de client ze bijwerkt — anders erft een artiest de kleuren van de
     118      // vorige pagina (bv. hub-paars i.p.v. eigen groen). Zelfde afleiding als shell.ejs.
     119      const _navAccent = (_site && _site.accent && /^#[0-9a-fA-F]{6}$/.test(_site.accent))
     120        ? _site.accent : '#c2410c';
     121      const _navPalette = (_site && _site.palette) ? _site.palette : 'sage';
    115122      const triggerJson = JSON.stringify({
    116         pcmsNav: { bodyClass: locals.bodyClass },
     123        pcmsNav: { bodyClass: locals.bodyClass, accent: _navAccent, palette: _navPalette },
    117124        pcmsPostSwap: data.post ? {
    118125          title: data.post.title,
  • src/views/shell.ejs

    ree25d45 ra3e2f17  
    330330
    331331  document.body.addEventListener('pcmsNav', function(ev) {
    332     var next = ev.detail && ev.detail.bodyClass;
     332    var d = ev.detail || {};
     333    // Per-site accent + palette bijwerken (head wordt niet mee-geswapt bij htmx-nav,
     334    // dus zonder dit erft een artiest de kleuren van de vorige pagina).
     335    if (d.accent && /^#[0-9a-fA-F]{6}$/.test(d.accent)) {
     336      var sa = document.getElementById('pcms-site-accent');
     337      if (sa) {
     338        sa.textContent =
     339          ':root,[data-palette]{--accent:' + d.accent +
     340          ';--accent-soft:color-mix(in srgb,' + d.accent + ' 80%,white)' +
     341          ';--accent-tint:color-mix(in srgb,' + d.accent + ' 12%,transparent);}';
     342      }
     343    }
     344    if (d.palette && /^[a-z0-9-]+$/i.test(d.palette)) {
     345      document.documentElement.setAttribute('data-palette', d.palette);
     346    }
     347
     348    var next = d.bodyClass;
    333349    if (!next) return;
    334350    // Server may send a multi-class string ("on-post extra"). Only the first
Note: See TracChangeset for help on using the changeset viewer.