bun-plugin-stx 0.2.220 → 0.2.222

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2180,9 +2180,28 @@ else {
2180
2180
  var isActive=href!=='/'?cur.startsWith(href):cur==='/';
2181
2181
  if(isExact)eac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
2182
2182
  if(isActive)ac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
2183
+ markCurrent(link,isExact);
2183
2184
  });
2184
2185
  }
2185
2186
 
2187
+ // aria-current="page" names the page the user is ON, so it has to move when
2188
+ // the page does. The server stamps it on the link for the page it rendered;
2189
+ // after that, only a full load would ever correct it, and a fragment swap is
2190
+ // not a full load. Left alone, a screen reader announces the entry the user
2191
+ // arrived through as current for the rest of the session, however far they
2192
+ // navigate \u2014 silently wrong, and only to the people relying on it.
2193
+ //
2194
+ // Only ever touched on links that already carry the attribute or are the
2195
+ // current one, so a page using aria-current for something else \u2014 a step in a
2196
+ // wizard, a sort direction \u2014 is not rewritten out from under itself.
2197
+ function markCurrent(link,isExact){
2198
+ if(isExact){
2199
+ if(link.getAttribute('aria-current')!=='page')link.setAttribute('aria-current','page');
2200
+ return;
2201
+ }
2202
+ if(link.getAttribute('aria-current')==='page')link.removeAttribute('aria-current');
2203
+ }
2204
+
2186
2205
  // \u2500\u2500 Progress bar DOM + style \u2500\u2500
2187
2206
  // Injects a fixed-position element at the top of the viewport plus the
2188
2207
  // minimal CSS for its transform/opacity transitions. Kept idempotent so
package/dist/serve.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  import {
4
- deriveLayoutGroup
4
+ extractLayoutMetadata
5
5
  } from "./chunk-93ete56h.js";
6
6
  import {
7
7
  __require
@@ -9587,7 +9587,7 @@ function __stxOverlay(errs){
9587
9587
  pageMiddlewarePatterns.length = 0;
9588
9588
  await Promise.all(files.map((f) => detectPageMiddleware(f)));
9589
9589
  try {
9590
- const { Router } = await import("./chunk-ebg5468e.js");
9590
+ const { Router } = await import("./chunk-qqcjq6v2.js");
9591
9591
  const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
9592
9592
  const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName() });
9593
9593
  if (!options.quiet)
@@ -10510,10 +10510,9 @@ ${html}`;
10510
10510
  const responseStatus = reqCtx.responseStatus ?? 200;
10511
10511
  const isSpaNav = req.headers.get(SPA_NAV_HEADER) === "true";
10512
10512
  if (isSpaNav) {
10513
- const layoutMatch = content.match(/<!-- stx-layout: ([^ ]+) -->/);
10514
- const pageLayout = layoutMatch ? layoutMatch[1] : "default";
10515
- const groupMetaMatch = content.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i);
10516
- const pageLayoutGroup = i18nConfig && i18nLocale ? `i18n:${i18nLocale}` : groupMetaMatch?.[1] || deriveLayoutGroup(pageLayout);
10513
+ const layoutMetadata = extractLayoutMetadata(content);
10514
+ const pageLayout = layoutMetadata.layout;
10515
+ const pageLayoutGroup = i18nConfig && i18nLocale ? `i18n:${i18nLocale}` : layoutMetadata.group;
10517
10516
  let fragment = content;
10518
10517
  let containerAttrs = "";
10519
10518
  let mainContentStart = -1;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.220",
4
+ "version": "0.2.222",
5
5
  "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",