Changeset 00d54bc in Klonkt
- Timestamp:
- 06/16/2026 03:38:33 AM (3 months ago)
- Branches:
- main
- Children:
- 5f43245
- Parents:
- baa2e59
- File:
-
- 1 edited
-
src/middleware/render.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/render.js
rbaa2e59 r00d54bc 95 95 96 96 if (isPartial) { 97 // HTMX: just send the content. Set HX-Trigger for body class swap 98 res.setHeader('HX-Trigger-After-Settle', JSON.stringify({ 97 // HTMX: just send the content. Set HX-Trigger for body class swap. 98 // HTTP-header values are Latin-1 only — a title with an em-dash, smart 99 // quote or emoji (e.g. "Welkom — gebouwd met Klonkt") would make 100 // setHeader throw ERR_INVALID_CHAR and 500 the partial, so the card 101 // looks "unclickable". Escape any non-ASCII to \uXXXX: the header stays 102 // ASCII-safe and remains valid JSON that htmx parses back unchanged. 103 const triggerJson = JSON.stringify({ 99 104 pcmsNav: { bodyClass: locals.bodyClass }, 100 105 pcmsPostSwap: data.post ? { … … 103 108 pageTitle: locals.pageTitle, 104 109 } : null, 105 })); 110 }).replace(/[-]/g, (ch) => '\\u' + ch.charCodeAt(0).toString(16).padStart(4, '0')); 111 res.setHeader('HX-Trigger-After-Settle', triggerJson); 106 112 return res.send(pageContent); 107 113 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)