bun-plugin-stx 0.2.313 → 0.2.315
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.
|
@@ -1673,7 +1673,7 @@ else {
|
|
|
1673
1673
|
// Remove old page scripts
|
|
1674
1674
|
document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
1675
1675
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
|
1676
|
-
updateNav(
|
|
1676
|
+
updateNav();
|
|
1677
1677
|
updateActiveLinks();
|
|
1678
1678
|
if(o.scrollToTop&&!hash)window.scrollTo({top:0,behavior:'instant'});
|
|
1679
1679
|
else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
|
|
@@ -2110,7 +2110,7 @@ else {
|
|
|
2110
2110
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
|
2111
2111
|
|
|
2112
2112
|
// Update active nav links
|
|
2113
|
-
updateNav(
|
|
2113
|
+
updateNav();
|
|
2114
2114
|
updateActiveLinks();
|
|
2115
2115
|
|
|
2116
2116
|
// Scroll
|
|
@@ -2507,33 +2507,59 @@ else {
|
|
|
2507
2507
|
}
|
|
2508
2508
|
|
|
2509
2509
|
// \u2500\u2500 Active link management \u2500\u2500
|
|
2510
|
-
|
|
2510
|
+
// Which links point at the page being shown. Every href is resolved against
|
|
2511
|
+
// the current URL first, because comparing the raw attribute with
|
|
2512
|
+
// location.pathname got most real links wrong:
|
|
2513
|
+
// - a query-only href (?range=24h, the shape of every range picker and tab
|
|
2514
|
+
// bar) never equalled a pathname, so the active one lost its classes and
|
|
2515
|
+
// had the server's aria-current="page" stripped on every load;
|
|
2516
|
+
// - /dashboard?site=1 was never an exact match for /dashboard;
|
|
2517
|
+
// - http://same-origin/x and /x/ were never matches for /x;
|
|
2518
|
+
// - /blog was "active" on /blogging, a prefix that is not a parent.
|
|
2519
|
+
// Null for links the router does not own (another origin, a bare #fragment,
|
|
2520
|
+
// anything unparseable), which are left exactly as the server rendered them.
|
|
2521
|
+
function normPath(p){return p.length>1&&p.charAt(p.length-1)==='/'?p.slice(0,-1):p}
|
|
2522
|
+
function linkState(href){
|
|
2523
|
+
if(!href||href.charAt(0)==='#')return null;
|
|
2524
|
+
var u;
|
|
2525
|
+
try{u=new URL(href,location.href)}catch(e){return null}
|
|
2526
|
+
if(u.origin!==location.origin)return null;
|
|
2527
|
+
var path=normPath(u.pathname),cur=normPath(location.pathname);
|
|
2528
|
+
// A link with no query matches on its path, so a nav entry stays current
|
|
2529
|
+
// while the page adds filters. A link WITH a query is current only when
|
|
2530
|
+
// every param it names has that value here: of five range links that all
|
|
2531
|
+
// point at this path, exactly one is.
|
|
2532
|
+
var have=new URLSearchParams(location.search),q=true;
|
|
2533
|
+
u.searchParams.forEach(function(v,k){if(have.getAll(k).indexOf(v)===-1)q=false});
|
|
2534
|
+
return {
|
|
2535
|
+
exact:q&&path===cur,
|
|
2536
|
+
active:q&&(path==='/'?cur==='/':(cur===path||cur.indexOf(path+'/')===0))
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
function updateNav(){
|
|
2511
2541
|
document.querySelectorAll('nav a[href], #mobileNav a[href], [data-stx-nav] a[href]').forEach(function(a){
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
if(isActive)ac.split(' ').forEach(function(cls){if(cls)a.classList.add(cls)});else ac.split(' ').forEach(function(cls){if(cls)a.classList.remove(cls)});
|
|
2518
|
-
}
|
|
2542
|
+
if(!a.hasAttribute('data-stx-link'))return;
|
|
2543
|
+
var st=linkState(a.getAttribute('href'));
|
|
2544
|
+
if(!st)return;
|
|
2545
|
+
var ac=a.getAttribute('data-stx-active-class')||'active';
|
|
2546
|
+
if(st.exact)ac.split(' ').forEach(function(cls){if(cls)a.classList.add(cls)});else ac.split(' ').forEach(function(cls){if(cls)a.classList.remove(cls)});
|
|
2519
2547
|
});
|
|
2520
2548
|
}
|
|
2521
2549
|
|
|
2522
2550
|
function updateActiveLinks(){
|
|
2523
2551
|
// Update active classes on <stx-link> elements (and legacy data-stx-link)
|
|
2524
2552
|
var links=document.querySelectorAll('[data-stx-link]');
|
|
2525
|
-
var cur=location.pathname;
|
|
2526
2553
|
links.forEach(function(link){
|
|
2527
|
-
var
|
|
2554
|
+
var st=linkState(link.getAttribute('to')||link.getAttribute('href')||'');
|
|
2555
|
+
if(!st)return;
|
|
2528
2556
|
var ac=link.getAttribute('active-class')||link.getAttribute('data-stx-active-class')||'active';
|
|
2529
2557
|
var eac=link.getAttribute('exact-active-class')||link.getAttribute('data-stx-exact-active-class')||'exact-active';
|
|
2530
2558
|
ac.split(' ').forEach(function(cls){if(cls)link.classList.remove(cls)});
|
|
2531
2559
|
eac.split(' ').forEach(function(cls){if(cls)link.classList.remove(cls)});
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
if(isActive)ac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
|
|
2536
|
-
markCurrent(link,isExact);
|
|
2560
|
+
if(st.exact)eac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
|
|
2561
|
+
if(st.active)ac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
|
|
2562
|
+
markCurrent(link,st.exact);
|
|
2537
2563
|
});
|
|
2538
2564
|
}
|
|
2539
2565
|
|
|
@@ -2657,7 +2683,7 @@ else {
|
|
|
2657
2683
|
injectStyles();
|
|
2658
2684
|
injectViewTransitionCSS();
|
|
2659
2685
|
updateActiveLinks();
|
|
2660
|
-
updateNav(
|
|
2686
|
+
updateNav();
|
|
2661
2687
|
}
|
|
2662
2688
|
|
|
2663
2689
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
package/dist/serve.js
CHANGED
|
@@ -9724,7 +9724,7 @@ function __stxOverlay(errs){
|
|
|
9724
9724
|
pageMiddlewarePatterns.length = 0;
|
|
9725
9725
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
9726
9726
|
try {
|
|
9727
|
-
const { Router } = await import("./chunk-
|
|
9727
|
+
const { Router } = await import("./chunk-3c6zbghg.js");
|
|
9728
9728
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9729
9729
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName() });
|
|
9730
9730
|
if (!options.quiet)
|
package/package.json
CHANGED