diff --git a/.gitignore b/.gitignore index 657842b..ef88793 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ node_modules/ .pnp.js # Build output -dist/ build/ *.tsbuildinfo diff --git a/dist/components/index.d.ts b/dist/components/index.d.ts new file mode 100644 index 0000000..c4d6e2b --- /dev/null +++ b/dist/components/index.d.ts @@ -0,0 +1,2 @@ +export { Explorer, ExplorerOptions } from '../index.js'; +import '@quartz-community/types'; diff --git a/dist/components/index.js b/dist/components/index.js new file mode 100644 index 0000000..e43cfa3 --- /dev/null +++ b/dist/components/index.js @@ -0,0 +1,212 @@ +import { jsxs, jsx } from 'preact/jsx-runtime'; + +// src/components/OverflowList.tsx +var OverflowList = ({ + children, + ...props +}) => { + return /* @__PURE__ */ jsxs("ul", { ...props, class: [props.class, "overflow"].filter(Boolean).join(" "), id: props.id, children: [ + children, + /* @__PURE__ */ jsx("li", { class: "overflow-end" }) + ] }); +}; +var numLists = 0; +var OverflowList_default = () => { + const id = `list-${numLists++}`; + return { + OverflowList: (props) => /* @__PURE__ */ jsx(OverflowList, { ...props, id }), + overflowListAfterDOMLoaded: ` +document.addEventListener("nav", (e) => { + const observer = new IntersectionObserver((entries) => { + for (const entry of entries) { + const parentUl = entry.target.parentElement + if (!parentUl) return + if (entry.isIntersecting) { + parentUl.classList.remove("gradient-active") + } else { + parentUl.classList.add("gradient-active") + } + } + }) + + const ul = document.getElementById("${id}") + if (!ul) return + + const end = ul.querySelector(".overflow-end") + if (!end) return + + observer.observe(end) + window.addCleanup(() => observer.disconnect()) +}) +` + }; +}; + +// src/util/lang.ts +function classNames(...classes) { + return classes.filter(Boolean).join(" "); +} + +// src/i18n/locales/en-US.ts +var en_US_default = { + components: { + explorer: { + title: "Explorer" + } + } +}; + +// src/i18n/index.ts +var locales = { + "en-US": en_US_default +}; +function i18n(locale) { + return locales[locale] || en_US_default; +} + +// src/components/styles/explorer.scss +var explorer_default = "@media all and (max-width: 800px) {\n .page > #quartz-body > :not(.sidebar.left:has(.explorer)) {\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body.lock-scroll > :not(.sidebar.left:has(.explorer)) {\n transform: translateX(100dvw);\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body .sidebar.left:has(.explorer) {\n box-sizing: border-box;\n position: sticky;\n background-color: var(--light);\n padding: 1rem 0 1rem 0;\n margin: 0;\n }\n .page > #quartz-body .hide-until-loaded ~ .explorer-content {\n display: none;\n }\n}\n.explorer {\n display: flex;\n flex-direction: column;\n overflow-y: hidden;\n min-height: 1.2rem;\n flex: 0 1 auto;\n}\n\n.explorer.collapsed {\n flex: 0 1 1.2rem;\n}\n\n.explorer.collapsed .fold {\n transform: rotateZ(-90deg);\n}\n\n.explorer .fold {\n margin-left: 0.5rem;\n transition: transform 0.3s ease;\n opacity: 0.8;\n}\n\n@media all and (max-width: 800px) {\n .explorer {\n order: -1;\n height: initial;\n overflow: hidden;\n flex-shrink: 0;\n align-self: flex-start;\n margin-top: auto;\n margin-bottom: auto;\n }\n}\n.explorer button.mobile-explorer {\n display: none;\n}\n\n.explorer button.desktop-explorer {\n display: flex;\n}\n\n@media all and (max-width: 800px) {\n .explorer button.mobile-explorer {\n display: flex;\n }\n .explorer button.desktop-explorer {\n display: none;\n }\n}\n.explorer svg {\n pointer-events: all;\n transition: transform 0.35s ease;\n}\n\n.explorer svg > polyline {\n pointer-events: none;\n}\n\nbutton.mobile-explorer,\nbutton.desktop-explorer {\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding: 0;\n color: var(--dark);\n display: flex;\n align-items: center;\n}\n\nbutton.mobile-explorer h2,\nbutton.desktop-explorer h2 {\n font-size: 1rem;\n display: inline-block;\n margin: 0;\n}\n\n.explorer-content {\n list-style: none;\n overflow: hidden;\n overflow-y: auto;\n margin-top: 0.5rem;\n}\n\n.explorer-content ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n.explorer-content ul.explorer-ul {\n overscroll-behavior: contain;\n}\n\n.explorer-content ul li > a {\n color: var(--dark);\n opacity: 0.75;\n pointer-events: all;\n}\n\n.explorer-content ul li > a.active {\n opacity: 1;\n color: var(--tertiary);\n}\n\n.explorer-content .folder-outer {\n visibility: collapse;\n display: grid;\n grid-template-rows: 0fr;\n transition-property: grid-template-rows, visibility;\n transition-duration: 0.3s;\n transition-timing-function: ease-in-out;\n}\n\n.explorer-content .folder-outer.open {\n visibility: visible;\n grid-template-rows: 1fr;\n}\n\n.explorer-content .folder-outer > ul {\n overflow: hidden;\n margin-left: 6px;\n padding-left: 0.8rem;\n border-left: 1px solid var(--lightgray);\n}\n\n.folder-container {\n flex-direction: row;\n display: flex;\n align-items: center;\n user-select: none;\n}\n\n.folder-container div > a {\n color: var(--secondary);\n font-family: var(--headerFont);\n font-size: 0.95rem;\n font-weight: 600;\n line-height: 1.5rem;\n display: inline-block;\n}\n\n.folder-container div > a:hover {\n color: var(--tertiary);\n}\n\n.folder-container div > button {\n color: var(--dark);\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding-left: 0;\n padding-right: 0;\n display: flex;\n align-items: center;\n font-family: var(--headerFont);\n}\n\n.folder-container div > button span {\n font-size: 0.95rem;\n display: inline-block;\n color: var(--secondary);\n font-weight: 600;\n margin: 0;\n line-height: 1.5rem;\n pointer-events: none;\n}\n\n.folder-icon {\n margin-right: 5px;\n color: var(--secondary);\n cursor: pointer;\n transition: transform 0.3s ease;\n backface-visibility: visible;\n flex-shrink: 0;\n}\n\nli:has(> .folder-outer:not(.open)) > .folder-container > svg {\n transform: rotate(-90deg);\n}\n\n.folder-icon:hover {\n color: var(--tertiary);\n}\n\n@media all and (max-width: 800px) {\n .explorer.collapsed {\n flex: 0 0 34px;\n }\n .explorer.collapsed > .explorer-content {\n transform: translateX(-100vw);\n visibility: hidden;\n }\n .explorer:not(.collapsed) {\n flex: 0 0 34px;\n }\n .explorer:not(.collapsed) > .explorer-content {\n transform: translateX(0);\n visibility: visible;\n }\n .explorer .explorer-content {\n box-sizing: border-box;\n z-index: 100;\n position: absolute;\n top: 0;\n left: 0;\n margin-top: 0;\n background-color: var(--light);\n max-width: 100vw;\n width: 100vw;\n transform: translateX(-100vw);\n transition: transform 200ms ease, visibility 200ms ease;\n overflow: hidden;\n padding: 4rem 0 2rem 0;\n height: 100dvh;\n max-height: 100dvh;\n visibility: hidden;\n }\n .explorer .mobile-explorer {\n margin: 0;\n padding: 5px;\n z-index: 101;\n }\n .explorer .mobile-explorer.hide-until-loaded {\n display: none;\n }\n .explorer .mobile-explorer .lucide-menu {\n stroke: var(--darkgray);\n }\n}\n@media all and (max-width: 800px) {\n .mobile-no-scroll .explorer-content > .explorer-ul {\n overscroll-behavior: contain;\n }\n}"; + +// src/components/scripts/explorer.inline.ts +var explorer_inline_default = `var Tu=Object.hasOwnProperty;var X,A,Y,_u,S,G,uu,eu,tu,$,H,M,fu,O={},nu=[],du=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,j=Array.isArray;function y(u,e){for(var t in e)u[t]=e[t];return u}function J(u){u&&u.parentNode&&u.parentNode.removeChild(u)}function R(u,e,t,o,l){var r={type:u,props:e,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++Y,__i:-1,__u:0};return l==null&&A.vnode!=null&&A.vnode(r),r}function L(u){return u.children}function N(u,e){this.props=u,this.context=e}function w(u,e){if(e==null)return u.__?w(u.__,u.__i+1):null;for(var t;es&&S.sort(eu),u=S.shift(),s=S.length,u.__d&&(t=void 0,o=void 0,l=(o=(e=u).__v).__e,r=[],i=[],e.__P&&((t=y({},o)).__v=o.__v+1,A.vnode&&A.vnode(t),Du(e.__P,t,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,r,l??w(o),!!(32&o.__u),i),t.__v=o.__v,t.__.__k[t.__i]=t,Cu(r,t,i),o.__e=o.__=null,t.__e!=l&&ru(t)));W.__r=0}function ou(u,e,t,o,l,r,i,s,d,D,c){var n,p,F,_,E,C,a,f=o&&o.__k||nu,h=e.length;for(d=pu(t,e,f,d,h),n=0;n0?i=u.__k[r]=R(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):u.__k[r]=i,d=r+p,i.__=u,i.__b=u.__b+1,s=null,(D=i.__i=Eu(i,t,d,n))!=-1&&(n--,(s=t[D])&&(s.__u|=2)),s==null||s.__v==null?(D==-1&&(l>c?p--:ld?p--:p++,i.__u|=4))):u.__k[r]=null;if(n)for(r=0;r(c?1:0)){for(l=t-1,r=t+1;l>=0||r=0?l--:r++])!=null&&(2&D.__u)==0&&s==D.key&&d==D.type)return i}return-1}function Z(u,e,t){e[0]=="-"?u.setProperty(e,t??""):u[e]=t==null?"":typeof t!="number"||du.test(e)?t:t+"px"}function P(u,e,t,o,l){var r,i;u:if(e=="style")if(typeof t=="string")u.style.cssText=t;else{if(typeof o=="string"&&(u.style.cssText=o=""),o)for(e in o)t&&e in t||Z(u.style,e,"");if(t)for(e in t)o&&t[e]==o[e]||Z(u.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(tu,"$1")),i=e.toLowerCase(),e=i in u||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),u.l||(u.l={}),u.l[e+r]=t,t?o?t.u=o.u:(t.u=$,u.addEventListener(e,r?M:H,r)):u.removeEventListener(e,r?M:H,r);else{if(l=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in u)try{u[e]=t??"";break u}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?u.removeAttribute(e):u.setAttribute(e,e=="popover"&&t==1?"":t))}}function Q(u){return function(e){if(this.l){var t=this.l[e.type+u];if(e.t==null)e.t=$++;else if(e.t0?u:j(u)?u.map(iu):y({},u)}function hu(u,e,t,o,l,r,i,s,d){var D,c,n,p,F,_,E,C=t.props||O,a=e.props,f=e.type;if(f=="svg"?l="http://www.w3.org/2000/svg":f=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),r!=null){for(D=0;Di.slugSegment===o);l||(l=this.makeChild(e,void 0));let r=(t.filePath||t.slug||"").split("/");l.fileSegmentHint=r[r.length-e.length],l.insert(e.slice(1),t)}}add(e){this.insert(e.slug.split("/"),e)}sort(e){this.children.sort(e),this.children.forEach(t=>t.sort(e))}filter(e){this.children=this.children.filter(e),this.children.forEach(t=>t.filter(e))}map(e){e(this),this.children.forEach(t=>t.map(e))}static fromEntries(e){let t=new u([],null);return e.forEach(([,o])=>t.add(o)),t}},yu=(u,e)=>!u.isFolder&&!e.isFolder||u.isFolder&&e.isFolder?u.displayName.localeCompare(e.displayName,void 0,{numeric:!0,sensitivity:"base"}):!u.isFolder&&e.isFolder?1:-1,xu=u=>u.slugSegment!=="tags";function Su(u,e,t,o){return t&&u.filter(t),o&&u.map(o),e&&u.sort(e),u}async function bu(u){try{console.log("[Explorer] Fetching content index...");let t=await(await fetch("/static/contentIndex.json")).json();if(console.log("[Explorer] Fetched data keys:",Object.keys(t).slice(0,5)),!t)return console.error("[Explorer] No data received"),null;let o=t.content||t,l=Object.entries(o);if(console.log("[Explorer] Entry count:",l.length),l.length===0)return console.warn("[Explorer] No content entries found"),null;let r=V.fromEntries(l);console.log("[Explorer] Trie root children:",r.children.length);let i=yu,s=xu,d=null;if(u)try{let D=JSON.parse(u);D.sortFn&&(i=new Function("a","b","return ("+D.sortFn+")(a, b)")),D.filterFn&&(s=new Function("node","return ("+D.filterFn+")(node)")),D.mapFn&&(d=new Function("node","("+D.mapFn+")(node)"))}catch(D){console.error("Error parsing data functions:",D)}return Su(r,i,s,d)}catch(e){return console.error("Error building file trie:",e),null}}var Fu=0;function cu(u,e,t,o,l,r=""){let i=document.getElementById("template-folder"),s=document.getElementById("template-file");if(!i||!s)return;let d=r?r+"/"+u.slugSegment:u.slugSegment,D=I(t);if(u.isFolder){let c=i.content.cloneNode(!0),n=c.querySelector(".folder-container"),p=c.querySelector(".folder-button"),F=c.querySelector(".folder-title"),_=c.querySelector(".folder-outer"),E=c.querySelector(".content");if(F&&(F.textContent=u.displayName||u.slugSegment),n&&(n.dataset.folderpath=u.slug),o==="link"&&p){let h=document.createElement("a");h.className=p.className;let g=I(u.slug);h.href="/"+(g||""),F?h.appendChild(F):h.textContent=u.displayName||u.slugSegment,p.replaceWith(h),p=h}let C=l[u.slug]!==void 0?l[u.slug]:!0,a=I(u.slug),f=a&&a===D.slice(0,a.length);if((!C||f)&&_&&_.classList.add("open"),u.children&&u.children.length>0&&E)for(let h of u.children)cu(h,E,t,o,l,d);e.appendChild(c)}else if(u.data){let c=s.content.cloneNode(!0),n=c.querySelector("a");n&&(n.href="/"+u.data.slug,n.textContent=u.displayName||u.slugSegment,u.data.slug===t&&n.classList.add("active")),e.appendChild(c)}}async function au(u){let e=++Fu;try{console.log("[Explorer] Nav event received, generation:",e);let t=(u.detail?.url||"").replace(/^\\/+/,""),o=document.querySelectorAll("div.explorer");console.log("[Explorer] Found",o.length,"explorers");let l={};try{JSON.parse(localStorage.getItem("fileTree")||"[]").forEach(i=>{l[i.path]=i.collapsed})}catch(r){console.error("[Explorer] Error loading saved state:",r)}for(let r of o){let i=r.querySelector(".explorer-ul");if(!i){console.warn("[Explorer] No explorer-ul found");continue}i.innerHTML='
  • ';let s=r.dataset.dataFns,d=r.dataset.behavior||"collapse";console.log("[Explorer] Starting tree build...");let D=await bu(s);if(e===Fu){if(console.log("[Explorer] Render generation is current, rendering tree"),console.log("[Explorer] Trie result:",D?"success":"null"),D&&D.children&&D.children.length>0){i.innerHTML='
  • ',console.log("[Explorer] Rendering",D.children.length,"children");for(let E of D.children)cu(E,i,t,d,l,"");console.log("[Explorer] Render complete, final list length:",i.children.length)}else console.warn("[Explorer] No trie or empty children");let _=sessionStorage.getItem("explorerScrollTop");if(_)i.scrollTop=parseInt(_,10);else{let E=i.querySelector(".active");E&&E.scrollIntoView({behavior:"smooth"})}}else console.log("[Explorer] Stale render generation, skipping tree render");let c=[],n=r.getElementsByClassName("explorer-toggle");for(let _ of n){let E=function(){let C=this.closest(".explorer");if(!C)return;let a=C.classList.toggle("collapsed");C.setAttribute("aria-expanded",a?"false":"true"),a?document.documentElement.classList.remove("mobile-no-scroll"):document.documentElement.classList.add("mobile-no-scroll")};_.addEventListener("click",E),c.push(()=>_.removeEventListener("click",E))}let p=r.getElementsByClassName("folder-icon");for(let _ of p){let E=function(C){C.stopPropagation();let a=this.parentElement;if(!a)return;let f=a.nextElementSibling;if(!f)return;f.classList.toggle("open");let h=!f.classList.contains("open"),g=a.dataset.folderpath,B=JSON.parse(localStorage.getItem("fileTree")||"[]"),m=B.findIndex(x=>x.path===g);m>=0?B[m].collapsed=h:B.push({path:g,collapsed:h}),localStorage.setItem("fileTree",JSON.stringify(B))};_.addEventListener("click",E),c.push(()=>_.removeEventListener("click",E))}let F=r.getElementsByClassName("folder-button");for(let _ of F){let E=function(C){let a=this.closest(".folder-container");if(!a)return;let f=r.dataset.behavior||"collapse",h=a.nextElementSibling,g=a.dataset.folderpath;if(f!=="link"){if(C.stopPropagation(),!h)return;h.classList.toggle("open");let B=!h.classList.contains("open"),m=JSON.parse(localStorage.getItem("fileTree")||"[]"),x=m.findIndex(b=>b.path===g);x>=0?m[x].collapsed=B:m.push({path:g,collapsed:B}),localStorage.setItem("fileTree",JSON.stringify(m))}};_.addEventListener("click",E),c.push(()=>_.removeEventListener("click",E))}typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>c.forEach(_=>_()))}for(let r of document.getElementsByClassName("explorer")){let i=r.querySelector(".mobile-explorer");i&&(i.classList.remove("hide-until-loaded"),i.checkVisibility&&i.checkVisibility()&&(r.classList.add("collapsed"),r.setAttribute("aria-expanded","false"),document.documentElement.classList.remove("mobile-no-scroll")))}}catch(t){console.error("[Explorer] Fatal error in nav handler:",t)}}document.addEventListener("nav",au);document.addEventListener("render",au);document.addEventListener("prenav",()=>{let u=document.querySelector(".explorer-ul");u&&sessionStorage.setItem("explorerScrollTop",u.scrollTop.toString())}); +`; +var defaultOptions = { + folderDefaultState: "collapsed", + folderClickBehavior: "link", + useSavedState: true, + mapFn: (node) => { + return node; + }, + sortFn: (a, b) => { + if (!a.isFolder && !b.isFolder || a.isFolder && b.isFolder) { + return (a.displayName || "").localeCompare(b.displayName || "", void 0, { + numeric: true, + sensitivity: "base" + }); + } + if (!a.isFolder && b.isFolder) { + return 1; + } + return -1; + }, + filterFn: (node) => node.slugSegment !== "tags", + order: ["filter", "map", "sort"] +}; +var numExplorers = 0; +function concatenateResources(...resources) { + return resources.filter((r) => !!r).join("\n"); +} +var Explorer_default = ((userOpts) => { + const opts = { ...defaultOptions, ...userOpts }; + const { OverflowList: OverflowList2, overflowListAfterDOMLoaded } = OverflowList_default(); + const ExplorerComponent = (props) => { + const { cfg } = props; + const displayClass = props.displayClass; + const id = `explorer-${numExplorers++}`; + const locale = cfg?.locale ?? "en-US"; + const title = opts.title ?? i18n(locale).components.explorer.title; + return /* @__PURE__ */ jsxs( + "div", + { + class: classNames(displayClass, "explorer"), + "data-behavior": opts.folderClickBehavior, + "data-collapsed": opts.folderDefaultState, + "data-savestate": opts.useSavedState, + "data-data-fns": JSON.stringify({ + order: opts.order, + sortFn: opts.sortFn?.toString(), + filterFn: opts.filterFn?.toString(), + mapFn: opts.mapFn?.toString() + }), + children: [ + /* @__PURE__ */ jsx( + "button", + { + type: "button", + class: "explorer-toggle mobile-explorer hide-until-loaded", + "data-mobile": true, + "aria-controls": id, + children: /* @__PURE__ */ jsxs( + "svg", + { + xmlns: "http://www.w3.org/2000/svg", + width: "24", + height: "24", + viewBox: "0 0 24 24", + "stroke-width": "2", + "stroke-linecap": "round", + "stroke-linejoin": "round", + class: "lucide-menu", + children: [ + /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" }), + /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "6", y2: "6" }), + /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "18", y2: "18" }) + ] + } + ) + } + ), + /* @__PURE__ */ jsxs( + "button", + { + type: "button", + class: "title-button explorer-toggle desktop-explorer", + "data-mobile": false, + "aria-expanded": true, + children: [ + /* @__PURE__ */ jsx("h2", { children: title }), + /* @__PURE__ */ jsx( + "svg", + { + xmlns: "http://www.w3.org/2000/svg", + width: "14", + height: "14", + viewBox: "5 8 14 8", + fill: "none", + stroke: "currentColor", + "stroke-width": "2", + "stroke-linecap": "round", + "stroke-linejoin": "round", + class: "fold", + children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" }) + } + ) + ] + } + ), + /* @__PURE__ */ jsx("div", { id, class: "explorer-content", "aria-expanded": false, role: "group", children: /* @__PURE__ */ jsx(OverflowList2, { class: "explorer-ul" }) }), + /* @__PURE__ */ jsx("template", { id: "template-file", children: /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", { href: "#" }) }) }), + /* @__PURE__ */ jsx("template", { id: "template-folder", children: /* @__PURE__ */ jsxs("li", { children: [ + /* @__PURE__ */ jsxs("div", { class: "folder-container", children: [ + /* @__PURE__ */ jsx( + "svg", + { + xmlns: "http://www.w3.org/2000/svg", + width: "12", + height: "12", + viewBox: "5 8 14 8", + fill: "none", + stroke: "currentColor", + "stroke-width": "2", + "stroke-linecap": "round", + "stroke-linejoin": "round", + class: "folder-icon", + children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" }) + } + ), + /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", { class: "folder-button", children: /* @__PURE__ */ jsx("span", { class: "folder-title" }) }) }) + ] }), + /* @__PURE__ */ jsx("div", { class: "folder-outer", children: /* @__PURE__ */ jsx("ul", { class: "content" }) }) + ] }) }) + ] + } + ); + }; + ExplorerComponent.css = explorer_default; + ExplorerComponent.afterDOMLoaded = concatenateResources(explorer_inline_default, overflowListAfterDOMLoaded); + return ExplorerComponent; +}); + +export { Explorer_default as Explorer }; +//# sourceMappingURL=index.js.map +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/components/index.js.map b/dist/components/index.js.map new file mode 100644 index 0000000..da14f33 --- /dev/null +++ b/dist/components/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/components/OverflowList.tsx","../../src/util/lang.ts","../../src/i18n/locales/en-US.ts","../../src/i18n/index.ts","../../src/components/styles/explorer.scss","../../src/components/scripts/explorer.inline.ts","../../src/components/Explorer.tsx"],"names":["OverflowList","jsxs","jsx"],"mappings":";;;AAEA,IAAM,eAAe,CAAC;AAAA,EACpB,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAA6D;AAC3D,EAAA,4BACG,IAAA,EAAA,EAAI,GAAG,OAAO,KAAA,EAAO,CAAC,MAAM,KAAA,EAAO,UAAU,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,EAAG,EAAA,EAAI,MAAM,EAAA,EAClF,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,oBACD,GAAA,CAAC,IAAA,EAAA,EAAG,KAAA,EAAM,cAAA,EAAe;AAAA,GAAA,EAC3B,CAAA;AAEJ,CAAA;AAEA,IAAI,QAAA,GAAW,CAAA;AAOf,IAAO,uBAAQ,MAA2B;AACxC,EAAA,MAAM,EAAA,GAAK,QAAQ,QAAA,EAAU,CAAA,CAAA;AAE7B,EAAA,OAAO;AAAA,IACL,cAAc,CAAC,KAAA,yBACZ,YAAA,EAAA,EAAc,GAAG,OAAO,EAAA,EAAQ,CAAA;AAAA,IAEnC,0BAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,sCAAA,EAcQ,EAAE,CAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,GAUxC;AACF,CAAA;;;ACrDO,SAAS,cAAc,O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kBACC,KAAA,EAAM,4BAAA;AAAA,kBACN,KAAA,EAAM,IAAA;AAAA,kBACN,MAAA,EAAO,IAAA;AAAA,kBACP,OAAA,EAAQ,UAAA;AAAA,kBACR,IAAA,EAAK,MAAA;AAAA,kBACL,MAAA,EAAO,cAAA;AAAA,kBACP,cAAA,EAAa,GAAA;AAAA,kBACb,gBAAA,EAAe,OAAA;AAAA,kBACf,iBAAA,EAAgB,OAAA;AAAA,kBAChB,KAAA,EAAM,aAAA;AAAA,kBAEN,QAAA,kBAAAA,GAAAA,CAAC,UAAA,EAAA,EAAS,MAAA,EAAO,gBAAA,EAAiB;AAAA;AAAA,eACpC;AAAA,8BACAA,GAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,IAAC,QAAA,EAAA,EAAO,KAAA,EAAM,eAAA,EACZ,QAAA,kBAAAA,GAAAA,CAAC,MAAA,EAAA,EAAK,KAAA,EAAM,cAAA,EAAe,GAC7B,CAAA,EACF;AAAA,aAAA,EACF,CAAA;AAAA,4BACAA,GAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAM,cAAA,EACT,0BAAAA,GAAAA,CAAC,IAAA,EAAA,EAAG,KAAA,EAAM,SAAA,EAAU,CAAA,EACtB;AAAA,WAAA,EACF,CAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ,CAAA;AAEA,EAAA,iBAAA,CAAkB,GAAA,GAAM,gBAAA;AACxB,EAAA,iBAAA,CAAkB,cAAA,GAAiB,oBAAA,CAAqB,uBAAA,EAAQ,0BAA0B,CAAA;AAC1F,EAAA,OAAO,iBAAA;AACT,CAAA","file":"index.js","sourcesContent":["import type { VNode, JSX } from \"preact\";\n\nconst OverflowList = ({\n children,\n ...props\n}: JSX.HTMLAttributes & { id: string }) => {\n return (\n
      \n {children}\n
    • \n
    \n );\n};\n\nlet numLists = 0;\n\nexport interface OverflowListFactory {\n OverflowList: (props: JSX.HTMLAttributes) => VNode;\n overflowListAfterDOMLoaded: string;\n}\n\nexport default (): OverflowListFactory => {\n const id = `list-${numLists++}`;\n\n return {\n OverflowList: (props: JSX.HTMLAttributes) => (\n \n ),\n overflowListAfterDOMLoaded: `\ndocument.addEventListener(\"nav\", (e) => {\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n const parentUl = entry.target.parentElement\n if (!parentUl) return\n if (entry.isIntersecting) {\n parentUl.classList.remove(\"gradient-active\")\n } else {\n parentUl.classList.add(\"gradient-active\")\n }\n }\n })\n\n const ul = document.getElementById(\"${id}\")\n if (!ul) return\n\n const end = ul.querySelector(\".overflow-end\")\n if (!end) return\n\n observer.observe(end)\n window.addCleanup(() => observer.disconnect())\n})\n`,\n };\n};\n","export function classNames(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n","export default {\n components: {\n explorer: {\n title: \"Explorer\",\n },\n },\n};\n","import enUS from \"./locales/en-US\";\n\nconst locales: Record = {\n \"en-US\": enUS,\n};\n\nexport function i18n(locale: string) {\n return locales[locale] || enUS;\n}\n","@media all and (max-width: 800px) {\n .page > #quartz-body > :not(.sidebar.left:has(.explorer)) {\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body.lock-scroll > :not(.sidebar.left:has(.explorer)) {\n transform: translateX(100dvw);\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body .sidebar.left:has(.explorer) {\n box-sizing: border-box;\n position: sticky;\n background-color: var(--light);\n padding: 1rem 0 1rem 0;\n margin: 0;\n }\n .page > #quartz-body .hide-until-loaded ~ .explorer-content {\n display: none;\n }\n}\n.explorer {\n display: flex;\n flex-direction: column;\n overflow-y: hidden;\n min-height: 1.2rem;\n flex: 0 1 auto;\n}\n\n.explorer.collapsed {\n flex: 0 1 1.2rem;\n}\n\n.explorer.collapsed .fold {\n transform: rotateZ(-90deg);\n}\n\n.explorer .fold {\n margin-left: 0.5rem;\n transition: transform 0.3s ease;\n opacity: 0.8;\n}\n\n@media all and (max-width: 800px) {\n .explorer {\n order: -1;\n height: initial;\n overflow: hidden;\n flex-shrink: 0;\n align-self: flex-start;\n margin-top: auto;\n margin-bottom: auto;\n }\n}\n.explorer button.mobile-explorer {\n display: none;\n}\n\n.explorer button.desktop-explorer {\n display: flex;\n}\n\n@media all and (max-width: 800px) {\n .explorer button.mobile-explorer {\n display: flex;\n }\n .explorer button.desktop-explorer {\n display: none;\n }\n}\n.explorer svg {\n pointer-events: all;\n transition: transform 0.35s ease;\n}\n\n.explorer svg > polyline {\n pointer-events: none;\n}\n\nbutton.mobile-explorer,\nbutton.desktop-explorer {\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding: 0;\n color: var(--dark);\n display: flex;\n align-items: center;\n}\n\nbutton.mobile-explorer h2,\nbutton.desktop-explorer h2 {\n font-size: 1rem;\n display: inline-block;\n margin: 0;\n}\n\n.explorer-content {\n list-style: none;\n overflow: hidden;\n overflow-y: auto;\n margin-top: 0.5rem;\n}\n\n.explorer-content ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n.explorer-content ul.explorer-ul {\n overscroll-behavior: contain;\n}\n\n.explorer-content ul li > a {\n color: var(--dark);\n opacity: 0.75;\n pointer-events: all;\n}\n\n.explorer-content ul li > a.active {\n opacity: 1;\n color: var(--tertiary);\n}\n\n.explorer-content .folder-outer {\n visibility: collapse;\n display: grid;\n grid-template-rows: 0fr;\n transition-property: grid-template-rows, visibility;\n transition-duration: 0.3s;\n transition-timing-function: ease-in-out;\n}\n\n.explorer-content .folder-outer.open {\n visibility: visible;\n grid-template-rows: 1fr;\n}\n\n.explorer-content .folder-outer > ul {\n overflow: hidden;\n margin-left: 6px;\n padding-left: 0.8rem;\n border-left: 1px solid var(--lightgray);\n}\n\n.folder-container {\n flex-direction: row;\n display: flex;\n align-items: center;\n user-select: none;\n}\n\n.folder-container div > a {\n color: var(--secondary);\n font-family: var(--headerFont);\n font-size: 0.95rem;\n font-weight: 600;\n line-height: 1.5rem;\n display: inline-block;\n}\n\n.folder-container div > a:hover {\n color: var(--tertiary);\n}\n\n.folder-container div > button {\n color: var(--dark);\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding-left: 0;\n padding-right: 0;\n display: flex;\n align-items: center;\n font-family: var(--headerFont);\n}\n\n.folder-container div > button span {\n font-size: 0.95rem;\n display: inline-block;\n color: var(--secondary);\n font-weight: 600;\n margin: 0;\n line-height: 1.5rem;\n pointer-events: none;\n}\n\n.folder-icon {\n margin-right: 5px;\n color: var(--secondary);\n cursor: pointer;\n transition: transform 0.3s ease;\n backface-visibility: visible;\n flex-shrink: 0;\n}\n\nli:has(> .folder-outer:not(.open)) > .folder-container > svg {\n transform: rotate(-90deg);\n}\n\n.folder-icon:hover {\n color: var(--tertiary);\n}\n\n@media all and (max-width: 800px) {\n .explorer.collapsed {\n flex: 0 0 34px;\n }\n .explorer.collapsed > .explorer-content {\n transform: translateX(-100vw);\n visibility: hidden;\n }\n .explorer:not(.collapsed) {\n flex: 0 0 34px;\n }\n .explorer:not(.collapsed) > .explorer-content {\n transform: translateX(0);\n visibility: visible;\n }\n .explorer .explorer-content {\n box-sizing: border-box;\n z-index: 100;\n position: absolute;\n top: 0;\n left: 0;\n margin-top: 0;\n background-color: var(--light);\n max-width: 100vw;\n width: 100vw;\n transform: translateX(-100vw);\n transition: transform 200ms ease, visibility 200ms ease;\n overflow: hidden;\n padding: 4rem 0 2rem 0;\n height: 100dvh;\n max-height: 100dvh;\n visibility: hidden;\n }\n .explorer .mobile-explorer {\n margin: 0;\n padding: 5px;\n z-index: 101;\n }\n .explorer .mobile-explorer.hide-until-loaded {\n display: none;\n }\n .explorer .mobile-explorer .lucide-menu {\n stroke: var(--darkgray);\n }\n}\n@media all and (max-width: 800px) {\n .mobile-no-scroll .explorer-content > .explorer-ul {\n overscroll-behavior: contain;\n }\n}","var Tu=Object.hasOwnProperty;var X,A,Y,_u,S,G,uu,eu,tu,$,H,M,fu,O={},nu=[],du=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,j=Array.isArray;function y(u,e){for(var t in e)u[t]=e[t];return u}function J(u){u&&u.parentNode&&u.parentNode.removeChild(u)}function R(u,e,t,o,l){var r={type:u,props:e,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++Y,__i:-1,__u:0};return l==null&&A.vnode!=null&&A.vnode(r),r}function L(u){return u.children}function N(u,e){this.props=u,this.context=e}function w(u,e){if(e==null)return u.__?w(u.__,u.__i+1):null;for(var t;es&&S.sort(eu),u=S.shift(),s=S.length,u.__d&&(t=void 0,o=void 0,l=(o=(e=u).__v).__e,r=[],i=[],e.__P&&((t=y({},o)).__v=o.__v+1,A.vnode&&A.vnode(t),Du(e.__P,t,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,r,l??w(o),!!(32&o.__u),i),t.__v=o.__v,t.__.__k[t.__i]=t,Cu(r,t,i),o.__e=o.__=null,t.__e!=l&&ru(t)));W.__r=0}function ou(u,e,t,o,l,r,i,s,d,D,c){var n,p,F,_,E,C,a,f=o&&o.__k||nu,h=e.length;for(d=pu(t,e,f,d,h),n=0;n0?i=u.__k[r]=R(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):u.__k[r]=i,d=r+p,i.__=u,i.__b=u.__b+1,s=null,(D=i.__i=Eu(i,t,d,n))!=-1&&(n--,(s=t[D])&&(s.__u|=2)),s==null||s.__v==null?(D==-1&&(l>c?p--:ld?p--:p++,i.__u|=4))):u.__k[r]=null;if(n)for(r=0;r(c?1:0)){for(l=t-1,r=t+1;l>=0||r=0?l--:r++])!=null&&(2&D.__u)==0&&s==D.key&&d==D.type)return i}return-1}function Z(u,e,t){e[0]==\"-\"?u.setProperty(e,t??\"\"):u[e]=t==null?\"\":typeof t!=\"number\"||du.test(e)?t:t+\"px\"}function P(u,e,t,o,l){var r,i;u:if(e==\"style\")if(typeof t==\"string\")u.style.cssText=t;else{if(typeof o==\"string\"&&(u.style.cssText=o=\"\"),o)for(e in o)t&&e in t||Z(u.style,e,\"\");if(t)for(e in t)o&&t[e]==o[e]||Z(u.style,e,t[e])}else if(e[0]==\"o\"&&e[1]==\"n\")r=e!=(e=e.replace(tu,\"$1\")),i=e.toLowerCase(),e=i in u||e==\"onFocusOut\"||e==\"onFocusIn\"?i.slice(2):e.slice(2),u.l||(u.l={}),u.l[e+r]=t,t?o?t.u=o.u:(t.u=$,u.addEventListener(e,r?M:H,r)):u.removeEventListener(e,r?M:H,r);else{if(l==\"http://www.w3.org/2000/svg\")e=e.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(e!=\"width\"&&e!=\"height\"&&e!=\"href\"&&e!=\"list\"&&e!=\"form\"&&e!=\"tabIndex\"&&e!=\"download\"&&e!=\"rowSpan\"&&e!=\"colSpan\"&&e!=\"role\"&&e!=\"popover\"&&e in u)try{u[e]=t??\"\";break u}catch{}typeof t==\"function\"||(t==null||t===!1&&e[4]!=\"-\"?u.removeAttribute(e):u.setAttribute(e,e==\"popover\"&&t==1?\"\":t))}}function Q(u){return function(e){if(this.l){var t=this.l[e.type+u];if(e.t==null)e.t=$++;else if(e.t0?u:j(u)?u.map(iu):y({},u)}function hu(u,e,t,o,l,r,i,s,d){var D,c,n,p,F,_,E,C=t.props||O,a=e.props,f=e.type;if(f==\"svg\"?l=\"http://www.w3.org/2000/svg\":f==\"math\"?l=\"http://www.w3.org/1998/Math/MathML\":l||(l=\"http://www.w3.org/1999/xhtml\"),r!=null){for(D=0;Di.slugSegment===o);l||(l=this.makeChild(e,void 0));let r=(t.filePath||t.slug||\"\").split(\"/\");l.fileSegmentHint=r[r.length-e.length],l.insert(e.slice(1),t)}}add(e){this.insert(e.slug.split(\"/\"),e)}sort(e){this.children.sort(e),this.children.forEach(t=>t.sort(e))}filter(e){this.children=this.children.filter(e),this.children.forEach(t=>t.filter(e))}map(e){e(this),this.children.forEach(t=>t.map(e))}static fromEntries(e){let t=new u([],null);return e.forEach(([,o])=>t.add(o)),t}},yu=(u,e)=>!u.isFolder&&!e.isFolder||u.isFolder&&e.isFolder?u.displayName.localeCompare(e.displayName,void 0,{numeric:!0,sensitivity:\"base\"}):!u.isFolder&&e.isFolder?1:-1,xu=u=>u.slugSegment!==\"tags\";function Su(u,e,t,o){return t&&u.filter(t),o&&u.map(o),e&&u.sort(e),u}async function bu(u){try{console.log(\"[Explorer] Fetching content index...\");let t=await(await fetch(\"/static/contentIndex.json\")).json();if(console.log(\"[Explorer] Fetched data keys:\",Object.keys(t).slice(0,5)),!t)return console.error(\"[Explorer] No data received\"),null;let o=t.content||t,l=Object.entries(o);if(console.log(\"[Explorer] Entry count:\",l.length),l.length===0)return console.warn(\"[Explorer] No content entries found\"),null;let r=V.fromEntries(l);console.log(\"[Explorer] Trie root children:\",r.children.length);let i=yu,s=xu,d=null;if(u)try{let D=JSON.parse(u);D.sortFn&&(i=new Function(\"a\",\"b\",\"return (\"+D.sortFn+\")(a, b)\")),D.filterFn&&(s=new Function(\"node\",\"return (\"+D.filterFn+\")(node)\")),D.mapFn&&(d=new Function(\"node\",\"(\"+D.mapFn+\")(node)\"))}catch(D){console.error(\"Error parsing data functions:\",D)}return Su(r,i,s,d)}catch(e){return console.error(\"Error building file trie:\",e),null}}var Fu=0;function cu(u,e,t,o,l,r=\"\"){let i=document.getElementById(\"template-folder\"),s=document.getElementById(\"template-file\");if(!i||!s)return;let d=r?r+\"/\"+u.slugSegment:u.slugSegment,D=I(t);if(u.isFolder){let c=i.content.cloneNode(!0),n=c.querySelector(\".folder-container\"),p=c.querySelector(\".folder-button\"),F=c.querySelector(\".folder-title\"),_=c.querySelector(\".folder-outer\"),E=c.querySelector(\".content\");if(F&&(F.textContent=u.displayName||u.slugSegment),n&&(n.dataset.folderpath=u.slug),o===\"link\"&&p){let h=document.createElement(\"a\");h.className=p.className;let g=I(u.slug);h.href=\"/\"+(g||\"\"),F?h.appendChild(F):h.textContent=u.displayName||u.slugSegment,p.replaceWith(h),p=h}let C=l[u.slug]!==void 0?l[u.slug]:!0,a=I(u.slug),f=a&&a===D.slice(0,a.length);if((!C||f)&&_&&_.classList.add(\"open\"),u.children&&u.children.length>0&&E)for(let h of u.children)cu(h,E,t,o,l,d);e.appendChild(c)}else if(u.data){let c=s.content.cloneNode(!0),n=c.querySelector(\"a\");n&&(n.href=\"/\"+u.data.slug,n.textContent=u.displayName||u.slugSegment,u.data.slug===t&&n.classList.add(\"active\")),e.appendChild(c)}}async function au(u){let e=++Fu;try{console.log(\"[Explorer] Nav event received, generation:\",e);let t=(u.detail?.url||\"\").replace(/^\\/+/,\"\"),o=document.querySelectorAll(\"div.explorer\");console.log(\"[Explorer] Found\",o.length,\"explorers\");let l={};try{JSON.parse(localStorage.getItem(\"fileTree\")||\"[]\").forEach(i=>{l[i.path]=i.collapsed})}catch(r){console.error(\"[Explorer] Error loading saved state:\",r)}for(let r of o){let i=r.querySelector(\".explorer-ul\");if(!i){console.warn(\"[Explorer] No explorer-ul found\");continue}i.innerHTML='
  • ';let s=r.dataset.dataFns,d=r.dataset.behavior||\"collapse\";console.log(\"[Explorer] Starting tree build...\");let D=await bu(s);if(e===Fu){if(console.log(\"[Explorer] Render generation is current, rendering tree\"),console.log(\"[Explorer] Trie result:\",D?\"success\":\"null\"),D&&D.children&&D.children.length>0){i.innerHTML='
  • ',console.log(\"[Explorer] Rendering\",D.children.length,\"children\");for(let E of D.children)cu(E,i,t,d,l,\"\");console.log(\"[Explorer] Render complete, final list length:\",i.children.length)}else console.warn(\"[Explorer] No trie or empty children\");let _=sessionStorage.getItem(\"explorerScrollTop\");if(_)i.scrollTop=parseInt(_,10);else{let E=i.querySelector(\".active\");E&&E.scrollIntoView({behavior:\"smooth\"})}}else console.log(\"[Explorer] Stale render generation, skipping tree render\");let c=[],n=r.getElementsByClassName(\"explorer-toggle\");for(let _ of n){let E=function(){let C=this.closest(\".explorer\");if(!C)return;let a=C.classList.toggle(\"collapsed\");C.setAttribute(\"aria-expanded\",a?\"false\":\"true\"),a?document.documentElement.classList.remove(\"mobile-no-scroll\"):document.documentElement.classList.add(\"mobile-no-scroll\")};_.addEventListener(\"click\",E),c.push(()=>_.removeEventListener(\"click\",E))}let p=r.getElementsByClassName(\"folder-icon\");for(let _ of p){let E=function(C){C.stopPropagation();let a=this.parentElement;if(!a)return;let f=a.nextElementSibling;if(!f)return;f.classList.toggle(\"open\");let h=!f.classList.contains(\"open\"),g=a.dataset.folderpath,B=JSON.parse(localStorage.getItem(\"fileTree\")||\"[]\"),m=B.findIndex(x=>x.path===g);m>=0?B[m].collapsed=h:B.push({path:g,collapsed:h}),localStorage.setItem(\"fileTree\",JSON.stringify(B))};_.addEventListener(\"click\",E),c.push(()=>_.removeEventListener(\"click\",E))}let F=r.getElementsByClassName(\"folder-button\");for(let _ of F){let E=function(C){let a=this.closest(\".folder-container\");if(!a)return;let f=r.dataset.behavior||\"collapse\",h=a.nextElementSibling,g=a.dataset.folderpath;if(f!==\"link\"){if(C.stopPropagation(),!h)return;h.classList.toggle(\"open\");let B=!h.classList.contains(\"open\"),m=JSON.parse(localStorage.getItem(\"fileTree\")||\"[]\"),x=m.findIndex(b=>b.path===g);x>=0?m[x].collapsed=B:m.push({path:g,collapsed:B}),localStorage.setItem(\"fileTree\",JSON.stringify(m))}};_.addEventListener(\"click\",E),c.push(()=>_.removeEventListener(\"click\",E))}typeof window<\"u\"&&window.addCleanup&&window.addCleanup(()=>c.forEach(_=>_()))}for(let r of document.getElementsByClassName(\"explorer\")){let i=r.querySelector(\".mobile-explorer\");i&&(i.classList.remove(\"hide-until-loaded\"),i.checkVisibility&&i.checkVisibility()&&(r.classList.add(\"collapsed\"),r.setAttribute(\"aria-expanded\",\"false\"),document.documentElement.classList.remove(\"mobile-no-scroll\")))}}catch(t){console.error(\"[Explorer] Fatal error in nav handler:\",t)}}document.addEventListener(\"nav\",au);document.addEventListener(\"render\",au);document.addEventListener(\"prenav\",()=>{let u=document.querySelector(\".explorer-ul\");u&&sessionStorage.setItem(\"explorerScrollTop\",u.scrollTop.toString())});\n","import type {\n QuartzComponent,\n QuartzComponentConstructor,\n QuartzComponentProps,\n} from \"@quartz-community/types\";\nimport OverflowListFactory from \"./OverflowList\";\nimport { classNames } from \"../util/lang\";\nimport { i18n } from \"../i18n\";\nimport style from \"./styles/explorer.scss\";\n// @ts-expect-error - Inline script loaded as text by esbuild plugin\nimport script from \"./scripts/explorer.inline.ts\";\n\ninterface FileTrieNode {\n slugSegment?: string;\n slugSegments?: string[];\n displayName?: string;\n isFolder: boolean;\n data: Record | null;\n children: FileTrieNode[];\n}\n\nexport interface ExplorerOptions {\n title?: string;\n folderDefaultState: \"collapsed\" | \"open\";\n folderClickBehavior: \"collapse\" | \"link\";\n useSavedState: boolean;\n sortFn?: (a: FileTrieNode, b: FileTrieNode) => number;\n filterFn?: (node: FileTrieNode) => boolean;\n mapFn?: (node: FileTrieNode) => FileTrieNode;\n order?: Array<\"filter\" | \"map\" | \"sort\">;\n}\n\nconst defaultOptions: ExplorerOptions = {\n folderDefaultState: \"collapsed\",\n folderClickBehavior: \"link\",\n useSavedState: true,\n mapFn: (node: FileTrieNode) => {\n return node;\n },\n sortFn: (a: FileTrieNode, b: FileTrieNode) => {\n if ((!a.isFolder && !b.isFolder) || (a.isFolder && b.isFolder)) {\n return (a.displayName || \"\").localeCompare(b.displayName || \"\", undefined, {\n numeric: true,\n sensitivity: \"base\",\n });\n }\n\n if (!a.isFolder && b.isFolder) {\n return 1;\n }\n return -1;\n },\n filterFn: (node: FileTrieNode) => node.slugSegment !== \"tags\",\n order: [\"filter\", \"map\", \"sort\"],\n};\n\nlet numExplorers = 0;\n\nfunction concatenateResources(...resources: (string | undefined)[]): string {\n return resources.filter((r): r is string => !!r).join(\"\\n\");\n}\n\nexport default ((userOpts?: Partial) => {\n const opts: ExplorerOptions = { ...defaultOptions, ...userOpts };\n const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory();\n\n const ExplorerComponent: QuartzComponent = (props: QuartzComponentProps) => {\n const { cfg } = props;\n const displayClass = (props as { displayClass?: \"mobile-only\" | \"desktop-only\" }).displayClass;\n const id = `explorer-${numExplorers++}`;\n const locale = cfg?.locale ?? \"en-US\";\n\n const title = opts.title ?? i18n(locale).components.explorer.title;\n\n return (\n \n \n \n \n \n \n \n \n \n

    {title}

    \n \n \n \n \n
    \n \n
    \n \n \n \n );\n };\n\n ExplorerComponent.css = style;\n ExplorerComponent.afterDOMLoaded = concatenateResources(script, overflowListAfterDOMLoaded);\n return ExplorerComponent;\n}) satisfies QuartzComponentConstructor;\n"]} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..857179b --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,23 @@ +import { QuartzComponent } from '@quartz-community/types'; + +interface FileTrieNode { + slugSegment?: string; + slugSegments?: string[]; + displayName?: string; + isFolder: boolean; + data: Record | null; + children: FileTrieNode[]; +} +interface ExplorerOptions { + title?: string; + folderDefaultState: "collapsed" | "open"; + folderClickBehavior: "collapse" | "link"; + useSavedState: boolean; + sortFn?: (a: FileTrieNode, b: FileTrieNode) => number; + filterFn?: (node: FileTrieNode) => boolean; + mapFn?: (node: FileTrieNode) => FileTrieNode; + order?: Array<"filter" | "map" | "sort">; +} +declare const _default: (userOpts?: Partial) => QuartzComponent; + +export { _default as Explorer, type ExplorerOptions }; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..e43cfa3 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,212 @@ +import { jsxs, jsx } from 'preact/jsx-runtime'; + +// src/components/OverflowList.tsx +var OverflowList = ({ + children, + ...props +}) => { + return /* @__PURE__ */ jsxs("ul", { ...props, class: [props.class, "overflow"].filter(Boolean).join(" "), id: props.id, children: [ + children, + /* @__PURE__ */ jsx("li", { class: "overflow-end" }) + ] }); +}; +var numLists = 0; +var OverflowList_default = () => { + const id = `list-${numLists++}`; + return { + OverflowList: (props) => /* @__PURE__ */ jsx(OverflowList, { ...props, id }), + overflowListAfterDOMLoaded: ` +document.addEventListener("nav", (e) => { + const observer = new IntersectionObserver((entries) => { + for (const entry of entries) { + const parentUl = entry.target.parentElement + if (!parentUl) return + if (entry.isIntersecting) { + parentUl.classList.remove("gradient-active") + } else { + parentUl.classList.add("gradient-active") + } + } + }) + + const ul = document.getElementById("${id}") + if (!ul) return + + const end = ul.querySelector(".overflow-end") + if (!end) return + + observer.observe(end) + window.addCleanup(() => observer.disconnect()) +}) +` + }; +}; + +// src/util/lang.ts +function classNames(...classes) { + return classes.filter(Boolean).join(" "); +} + +// src/i18n/locales/en-US.ts +var en_US_default = { + components: { + explorer: { + title: "Explorer" + } + } +}; + +// src/i18n/index.ts +var locales = { + "en-US": en_US_default +}; +function i18n(locale) { + return locales[locale] || en_US_default; +} + +// src/components/styles/explorer.scss +var explorer_default = "@media all and (max-width: 800px) {\n .page > #quartz-body > :not(.sidebar.left:has(.explorer)) {\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body.lock-scroll > :not(.sidebar.left:has(.explorer)) {\n transform: translateX(100dvw);\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body .sidebar.left:has(.explorer) {\n box-sizing: border-box;\n position: sticky;\n background-color: var(--light);\n padding: 1rem 0 1rem 0;\n margin: 0;\n }\n .page > #quartz-body .hide-until-loaded ~ .explorer-content {\n display: none;\n }\n}\n.explorer {\n display: flex;\n flex-direction: column;\n overflow-y: hidden;\n min-height: 1.2rem;\n flex: 0 1 auto;\n}\n\n.explorer.collapsed {\n flex: 0 1 1.2rem;\n}\n\n.explorer.collapsed .fold {\n transform: rotateZ(-90deg);\n}\n\n.explorer .fold {\n margin-left: 0.5rem;\n transition: transform 0.3s ease;\n opacity: 0.8;\n}\n\n@media all and (max-width: 800px) {\n .explorer {\n order: -1;\n height: initial;\n overflow: hidden;\n flex-shrink: 0;\n align-self: flex-start;\n margin-top: auto;\n margin-bottom: auto;\n }\n}\n.explorer button.mobile-explorer {\n display: none;\n}\n\n.explorer button.desktop-explorer {\n display: flex;\n}\n\n@media all and (max-width: 800px) {\n .explorer button.mobile-explorer {\n display: flex;\n }\n .explorer button.desktop-explorer {\n display: none;\n }\n}\n.explorer svg {\n pointer-events: all;\n transition: transform 0.35s ease;\n}\n\n.explorer svg > polyline {\n pointer-events: none;\n}\n\nbutton.mobile-explorer,\nbutton.desktop-explorer {\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding: 0;\n color: var(--dark);\n display: flex;\n align-items: center;\n}\n\nbutton.mobile-explorer h2,\nbutton.desktop-explorer h2 {\n font-size: 1rem;\n display: inline-block;\n margin: 0;\n}\n\n.explorer-content {\n list-style: none;\n overflow: hidden;\n overflow-y: auto;\n margin-top: 0.5rem;\n}\n\n.explorer-content ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n.explorer-content ul.explorer-ul {\n overscroll-behavior: contain;\n}\n\n.explorer-content ul li > a {\n color: var(--dark);\n opacity: 0.75;\n pointer-events: all;\n}\n\n.explorer-content ul li > a.active {\n opacity: 1;\n color: var(--tertiary);\n}\n\n.explorer-content .folder-outer {\n visibility: collapse;\n display: grid;\n grid-template-rows: 0fr;\n transition-property: grid-template-rows, visibility;\n transition-duration: 0.3s;\n transition-timing-function: ease-in-out;\n}\n\n.explorer-content .folder-outer.open {\n visibility: visible;\n grid-template-rows: 1fr;\n}\n\n.explorer-content .folder-outer > ul {\n overflow: hidden;\n margin-left: 6px;\n padding-left: 0.8rem;\n border-left: 1px solid var(--lightgray);\n}\n\n.folder-container {\n flex-direction: row;\n display: flex;\n align-items: center;\n user-select: none;\n}\n\n.folder-container div > a {\n color: var(--secondary);\n font-family: var(--headerFont);\n font-size: 0.95rem;\n font-weight: 600;\n line-height: 1.5rem;\n display: inline-block;\n}\n\n.folder-container div > a:hover {\n color: var(--tertiary);\n}\n\n.folder-container div > button {\n color: var(--dark);\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding-left: 0;\n padding-right: 0;\n display: flex;\n align-items: center;\n font-family: var(--headerFont);\n}\n\n.folder-container div > button span {\n font-size: 0.95rem;\n display: inline-block;\n color: var(--secondary);\n font-weight: 600;\n margin: 0;\n line-height: 1.5rem;\n pointer-events: none;\n}\n\n.folder-icon {\n margin-right: 5px;\n color: var(--secondary);\n cursor: pointer;\n transition: transform 0.3s ease;\n backface-visibility: visible;\n flex-shrink: 0;\n}\n\nli:has(> .folder-outer:not(.open)) > .folder-container > svg {\n transform: rotate(-90deg);\n}\n\n.folder-icon:hover {\n color: var(--tertiary);\n}\n\n@media all and (max-width: 800px) {\n .explorer.collapsed {\n flex: 0 0 34px;\n }\n .explorer.collapsed > .explorer-content {\n transform: translateX(-100vw);\n visibility: hidden;\n }\n .explorer:not(.collapsed) {\n flex: 0 0 34px;\n }\n .explorer:not(.collapsed) > .explorer-content {\n transform: translateX(0);\n visibility: visible;\n }\n .explorer .explorer-content {\n box-sizing: border-box;\n z-index: 100;\n position: absolute;\n top: 0;\n left: 0;\n margin-top: 0;\n background-color: var(--light);\n max-width: 100vw;\n width: 100vw;\n transform: translateX(-100vw);\n transition: transform 200ms ease, visibility 200ms ease;\n overflow: hidden;\n padding: 4rem 0 2rem 0;\n height: 100dvh;\n max-height: 100dvh;\n visibility: hidden;\n }\n .explorer .mobile-explorer {\n margin: 0;\n padding: 5px;\n z-index: 101;\n }\n .explorer .mobile-explorer.hide-until-loaded {\n display: none;\n }\n .explorer .mobile-explorer .lucide-menu {\n stroke: var(--darkgray);\n }\n}\n@media all and (max-width: 800px) {\n .mobile-no-scroll .explorer-content > .explorer-ul {\n overscroll-behavior: contain;\n }\n}"; + +// src/components/scripts/explorer.inline.ts +var explorer_inline_default = `var Tu=Object.hasOwnProperty;var X,A,Y,_u,S,G,uu,eu,tu,$,H,M,fu,O={},nu=[],du=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,j=Array.isArray;function y(u,e){for(var t in e)u[t]=e[t];return u}function J(u){u&&u.parentNode&&u.parentNode.removeChild(u)}function R(u,e,t,o,l){var r={type:u,props:e,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++Y,__i:-1,__u:0};return l==null&&A.vnode!=null&&A.vnode(r),r}function L(u){return u.children}function N(u,e){this.props=u,this.context=e}function w(u,e){if(e==null)return u.__?w(u.__,u.__i+1):null;for(var t;es&&S.sort(eu),u=S.shift(),s=S.length,u.__d&&(t=void 0,o=void 0,l=(o=(e=u).__v).__e,r=[],i=[],e.__P&&((t=y({},o)).__v=o.__v+1,A.vnode&&A.vnode(t),Du(e.__P,t,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,r,l??w(o),!!(32&o.__u),i),t.__v=o.__v,t.__.__k[t.__i]=t,Cu(r,t,i),o.__e=o.__=null,t.__e!=l&&ru(t)));W.__r=0}function ou(u,e,t,o,l,r,i,s,d,D,c){var n,p,F,_,E,C,a,f=o&&o.__k||nu,h=e.length;for(d=pu(t,e,f,d,h),n=0;n0?i=u.__k[r]=R(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):u.__k[r]=i,d=r+p,i.__=u,i.__b=u.__b+1,s=null,(D=i.__i=Eu(i,t,d,n))!=-1&&(n--,(s=t[D])&&(s.__u|=2)),s==null||s.__v==null?(D==-1&&(l>c?p--:ld?p--:p++,i.__u|=4))):u.__k[r]=null;if(n)for(r=0;r(c?1:0)){for(l=t-1,r=t+1;l>=0||r=0?l--:r++])!=null&&(2&D.__u)==0&&s==D.key&&d==D.type)return i}return-1}function Z(u,e,t){e[0]=="-"?u.setProperty(e,t??""):u[e]=t==null?"":typeof t!="number"||du.test(e)?t:t+"px"}function P(u,e,t,o,l){var r,i;u:if(e=="style")if(typeof t=="string")u.style.cssText=t;else{if(typeof o=="string"&&(u.style.cssText=o=""),o)for(e in o)t&&e in t||Z(u.style,e,"");if(t)for(e in t)o&&t[e]==o[e]||Z(u.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(tu,"$1")),i=e.toLowerCase(),e=i in u||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),u.l||(u.l={}),u.l[e+r]=t,t?o?t.u=o.u:(t.u=$,u.addEventListener(e,r?M:H,r)):u.removeEventListener(e,r?M:H,r);else{if(l=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in u)try{u[e]=t??"";break u}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?u.removeAttribute(e):u.setAttribute(e,e=="popover"&&t==1?"":t))}}function Q(u){return function(e){if(this.l){var t=this.l[e.type+u];if(e.t==null)e.t=$++;else if(e.t0?u:j(u)?u.map(iu):y({},u)}function hu(u,e,t,o,l,r,i,s,d){var D,c,n,p,F,_,E,C=t.props||O,a=e.props,f=e.type;if(f=="svg"?l="http://www.w3.org/2000/svg":f=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),r!=null){for(D=0;Di.slugSegment===o);l||(l=this.makeChild(e,void 0));let r=(t.filePath||t.slug||"").split("/");l.fileSegmentHint=r[r.length-e.length],l.insert(e.slice(1),t)}}add(e){this.insert(e.slug.split("/"),e)}sort(e){this.children.sort(e),this.children.forEach(t=>t.sort(e))}filter(e){this.children=this.children.filter(e),this.children.forEach(t=>t.filter(e))}map(e){e(this),this.children.forEach(t=>t.map(e))}static fromEntries(e){let t=new u([],null);return e.forEach(([,o])=>t.add(o)),t}},yu=(u,e)=>!u.isFolder&&!e.isFolder||u.isFolder&&e.isFolder?u.displayName.localeCompare(e.displayName,void 0,{numeric:!0,sensitivity:"base"}):!u.isFolder&&e.isFolder?1:-1,xu=u=>u.slugSegment!=="tags";function Su(u,e,t,o){return t&&u.filter(t),o&&u.map(o),e&&u.sort(e),u}async function bu(u){try{console.log("[Explorer] Fetching content index...");let t=await(await fetch("/static/contentIndex.json")).json();if(console.log("[Explorer] Fetched data keys:",Object.keys(t).slice(0,5)),!t)return console.error("[Explorer] No data received"),null;let o=t.content||t,l=Object.entries(o);if(console.log("[Explorer] Entry count:",l.length),l.length===0)return console.warn("[Explorer] No content entries found"),null;let r=V.fromEntries(l);console.log("[Explorer] Trie root children:",r.children.length);let i=yu,s=xu,d=null;if(u)try{let D=JSON.parse(u);D.sortFn&&(i=new Function("a","b","return ("+D.sortFn+")(a, b)")),D.filterFn&&(s=new Function("node","return ("+D.filterFn+")(node)")),D.mapFn&&(d=new Function("node","("+D.mapFn+")(node)"))}catch(D){console.error("Error parsing data functions:",D)}return Su(r,i,s,d)}catch(e){return console.error("Error building file trie:",e),null}}var Fu=0;function cu(u,e,t,o,l,r=""){let i=document.getElementById("template-folder"),s=document.getElementById("template-file");if(!i||!s)return;let d=r?r+"/"+u.slugSegment:u.slugSegment,D=I(t);if(u.isFolder){let c=i.content.cloneNode(!0),n=c.querySelector(".folder-container"),p=c.querySelector(".folder-button"),F=c.querySelector(".folder-title"),_=c.querySelector(".folder-outer"),E=c.querySelector(".content");if(F&&(F.textContent=u.displayName||u.slugSegment),n&&(n.dataset.folderpath=u.slug),o==="link"&&p){let h=document.createElement("a");h.className=p.className;let g=I(u.slug);h.href="/"+(g||""),F?h.appendChild(F):h.textContent=u.displayName||u.slugSegment,p.replaceWith(h),p=h}let C=l[u.slug]!==void 0?l[u.slug]:!0,a=I(u.slug),f=a&&a===D.slice(0,a.length);if((!C||f)&&_&&_.classList.add("open"),u.children&&u.children.length>0&&E)for(let h of u.children)cu(h,E,t,o,l,d);e.appendChild(c)}else if(u.data){let c=s.content.cloneNode(!0),n=c.querySelector("a");n&&(n.href="/"+u.data.slug,n.textContent=u.displayName||u.slugSegment,u.data.slug===t&&n.classList.add("active")),e.appendChild(c)}}async function au(u){let e=++Fu;try{console.log("[Explorer] Nav event received, generation:",e);let t=(u.detail?.url||"").replace(/^\\/+/,""),o=document.querySelectorAll("div.explorer");console.log("[Explorer] Found",o.length,"explorers");let l={};try{JSON.parse(localStorage.getItem("fileTree")||"[]").forEach(i=>{l[i.path]=i.collapsed})}catch(r){console.error("[Explorer] Error loading saved state:",r)}for(let r of o){let i=r.querySelector(".explorer-ul");if(!i){console.warn("[Explorer] No explorer-ul found");continue}i.innerHTML='
  • ';let s=r.dataset.dataFns,d=r.dataset.behavior||"collapse";console.log("[Explorer] Starting tree build...");let D=await bu(s);if(e===Fu){if(console.log("[Explorer] Render generation is current, rendering tree"),console.log("[Explorer] Trie result:",D?"success":"null"),D&&D.children&&D.children.length>0){i.innerHTML='
  • ',console.log("[Explorer] Rendering",D.children.length,"children");for(let E of D.children)cu(E,i,t,d,l,"");console.log("[Explorer] Render complete, final list length:",i.children.length)}else console.warn("[Explorer] No trie or empty children");let _=sessionStorage.getItem("explorerScrollTop");if(_)i.scrollTop=parseInt(_,10);else{let E=i.querySelector(".active");E&&E.scrollIntoView({behavior:"smooth"})}}else console.log("[Explorer] Stale render generation, skipping tree render");let c=[],n=r.getElementsByClassName("explorer-toggle");for(let _ of n){let E=function(){let C=this.closest(".explorer");if(!C)return;let a=C.classList.toggle("collapsed");C.setAttribute("aria-expanded",a?"false":"true"),a?document.documentElement.classList.remove("mobile-no-scroll"):document.documentElement.classList.add("mobile-no-scroll")};_.addEventListener("click",E),c.push(()=>_.removeEventListener("click",E))}let p=r.getElementsByClassName("folder-icon");for(let _ of p){let E=function(C){C.stopPropagation();let a=this.parentElement;if(!a)return;let f=a.nextElementSibling;if(!f)return;f.classList.toggle("open");let h=!f.classList.contains("open"),g=a.dataset.folderpath,B=JSON.parse(localStorage.getItem("fileTree")||"[]"),m=B.findIndex(x=>x.path===g);m>=0?B[m].collapsed=h:B.push({path:g,collapsed:h}),localStorage.setItem("fileTree",JSON.stringify(B))};_.addEventListener("click",E),c.push(()=>_.removeEventListener("click",E))}let F=r.getElementsByClassName("folder-button");for(let _ of F){let E=function(C){let a=this.closest(".folder-container");if(!a)return;let f=r.dataset.behavior||"collapse",h=a.nextElementSibling,g=a.dataset.folderpath;if(f!=="link"){if(C.stopPropagation(),!h)return;h.classList.toggle("open");let B=!h.classList.contains("open"),m=JSON.parse(localStorage.getItem("fileTree")||"[]"),x=m.findIndex(b=>b.path===g);x>=0?m[x].collapsed=B:m.push({path:g,collapsed:B}),localStorage.setItem("fileTree",JSON.stringify(m))}};_.addEventListener("click",E),c.push(()=>_.removeEventListener("click",E))}typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>c.forEach(_=>_()))}for(let r of document.getElementsByClassName("explorer")){let i=r.querySelector(".mobile-explorer");i&&(i.classList.remove("hide-until-loaded"),i.checkVisibility&&i.checkVisibility()&&(r.classList.add("collapsed"),r.setAttribute("aria-expanded","false"),document.documentElement.classList.remove("mobile-no-scroll")))}}catch(t){console.error("[Explorer] Fatal error in nav handler:",t)}}document.addEventListener("nav",au);document.addEventListener("render",au);document.addEventListener("prenav",()=>{let u=document.querySelector(".explorer-ul");u&&sessionStorage.setItem("explorerScrollTop",u.scrollTop.toString())}); +`; +var defaultOptions = { + folderDefaultState: "collapsed", + folderClickBehavior: "link", + useSavedState: true, + mapFn: (node) => { + return node; + }, + sortFn: (a, b) => { + if (!a.isFolder && !b.isFolder || a.isFolder && b.isFolder) { + return (a.displayName || "").localeCompare(b.displayName || "", void 0, { + numeric: true, + sensitivity: "base" + }); + } + if (!a.isFolder && b.isFolder) { + return 1; + } + return -1; + }, + filterFn: (node) => node.slugSegment !== "tags", + order: ["filter", "map", "sort"] +}; +var numExplorers = 0; +function concatenateResources(...resources) { + return resources.filter((r) => !!r).join("\n"); +} +var Explorer_default = ((userOpts) => { + const opts = { ...defaultOptions, ...userOpts }; + const { OverflowList: OverflowList2, overflowListAfterDOMLoaded } = OverflowList_default(); + const ExplorerComponent = (props) => { + const { cfg } = props; + const displayClass = props.displayClass; + const id = `explorer-${numExplorers++}`; + const locale = cfg?.locale ?? "en-US"; + const title = opts.title ?? i18n(locale).components.explorer.title; + return /* @__PURE__ */ jsxs( + "div", + { + class: classNames(displayClass, "explorer"), + "data-behavior": opts.folderClickBehavior, + "data-collapsed": opts.folderDefaultState, + "data-savestate": opts.useSavedState, + "data-data-fns": JSON.stringify({ + order: opts.order, + sortFn: opts.sortFn?.toString(), + filterFn: opts.filterFn?.toString(), + mapFn: opts.mapFn?.toString() + }), + children: [ + /* @__PURE__ */ jsx( + "button", + { + type: "button", + class: "explorer-toggle mobile-explorer hide-until-loaded", + "data-mobile": true, + "aria-controls": id, + children: /* @__PURE__ */ jsxs( + "svg", + { + xmlns: "http://www.w3.org/2000/svg", + width: "24", + height: "24", + viewBox: "0 0 24 24", + "stroke-width": "2", + "stroke-linecap": "round", + "stroke-linejoin": "round", + class: "lucide-menu", + children: [ + /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" }), + /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "6", y2: "6" }), + /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "18", y2: "18" }) + ] + } + ) + } + ), + /* @__PURE__ */ jsxs( + "button", + { + type: "button", + class: "title-button explorer-toggle desktop-explorer", + "data-mobile": false, + "aria-expanded": true, + children: [ + /* @__PURE__ */ jsx("h2", { children: title }), + /* @__PURE__ */ jsx( + "svg", + { + xmlns: "http://www.w3.org/2000/svg", + width: "14", + height: "14", + viewBox: "5 8 14 8", + fill: "none", + stroke: "currentColor", + "stroke-width": "2", + "stroke-linecap": "round", + "stroke-linejoin": "round", + class: "fold", + children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" }) + } + ) + ] + } + ), + /* @__PURE__ */ jsx("div", { id, class: "explorer-content", "aria-expanded": false, role: "group", children: /* @__PURE__ */ jsx(OverflowList2, { class: "explorer-ul" }) }), + /* @__PURE__ */ jsx("template", { id: "template-file", children: /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", { href: "#" }) }) }), + /* @__PURE__ */ jsx("template", { id: "template-folder", children: /* @__PURE__ */ jsxs("li", { children: [ + /* @__PURE__ */ jsxs("div", { class: "folder-container", children: [ + /* @__PURE__ */ jsx( + "svg", + { + xmlns: "http://www.w3.org/2000/svg", + width: "12", + height: "12", + viewBox: "5 8 14 8", + fill: "none", + stroke: "currentColor", + "stroke-width": "2", + "stroke-linecap": "round", + "stroke-linejoin": "round", + class: "folder-icon", + children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" }) + } + ), + /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", { class: "folder-button", children: /* @__PURE__ */ jsx("span", { class: "folder-title" }) }) }) + ] }), + /* @__PURE__ */ jsx("div", { class: "folder-outer", children: /* @__PURE__ */ jsx("ul", { class: "content" }) }) + ] }) }) + ] + } + ); + }; + ExplorerComponent.css = explorer_default; + ExplorerComponent.afterDOMLoaded = concatenateResources(explorer_inline_default, overflowListAfterDOMLoaded); + return ExplorerComponent; +}); + +export { Explorer_default as Explorer }; +//# sourceMappingURL=index.js.map +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..cd98613 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/components/OverflowList.tsx","../src/util/lang.ts","../src/i18n/locales/en-US.ts","../src/i18n/index.ts","../src/components/styles/explorer.scss","../src/components/scripts/explorer.inline.ts","../src/components/Explorer.tsx"],"names":["OverflowList","jsxs","jsx"],"mappings":";;;AAEA,IAAM,eAAe,CAAC;AAAA,EACpB,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAA6D;AAC3D,EAAA,4BACG,IAAA,EAAA,EAAI,GAAG,OAAO,KAAA,EAAO,CAAC,MAAM,KAAA,EAAO,UAAU,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,EAAG,EAAA,EAAI,MAAM,EAAA,EAClF,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,oBACD,GAAA,CAAC,IAAA,EAAA,EAAG,KAAA,EAAM,c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,EAAM,SAAA,EAAU,CAAA,EACtB;AAAA,WAAA,EACF,CAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ,CAAA;AAEA,EAAA,iBAAA,CAAkB,GAAA,GAAM,gBAAA;AACxB,EAAA,iBAAA,CAAkB,cAAA,GAAiB,oBAAA,CAAqB,uBAAA,EAAQ,0BAA0B,CAAA;AAC1F,EAAA,OAAO,iBAAA;AACT,CAAA","file":"index.js","sourcesContent":["import type { VNode, JSX } from \"preact\";\n\nconst OverflowList = ({\n children,\n ...props\n}: JSX.HTMLAttributes & { id: string }) => {\n return (\n
      \n {children}\n
    • \n
    \n );\n};\n\nlet numLists = 0;\n\nexport interface OverflowListFactory {\n OverflowList: (props: JSX.HTMLAttributes) => VNode;\n overflowListAfterDOMLoaded: string;\n}\n\nexport default (): OverflowListFactory => {\n const id = `list-${numLists++}`;\n\n return {\n OverflowList: (props: JSX.HTMLAttributes) => (\n \n ),\n overflowListAfterDOMLoaded: `\ndocument.addEventListener(\"nav\", (e) => {\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n const parentUl = entry.target.parentElement\n if (!parentUl) return\n if (entry.isIntersecting) {\n parentUl.classList.remove(\"gradient-active\")\n } else {\n parentUl.classList.add(\"gradient-active\")\n }\n }\n })\n\n const ul = document.getElementById(\"${id}\")\n if (!ul) return\n\n const end = ul.querySelector(\".overflow-end\")\n if (!end) return\n\n observer.observe(end)\n window.addCleanup(() => observer.disconnect())\n})\n`,\n };\n};\n","export function classNames(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n","export default {\n components: {\n explorer: {\n title: \"Explorer\",\n },\n },\n};\n","import enUS from \"./locales/en-US\";\n\nconst locales: Record = {\n \"en-US\": enUS,\n};\n\nexport function i18n(locale: string) {\n return locales[locale] || enUS;\n}\n","@media all and (max-width: 800px) {\n .page > #quartz-body > :not(.sidebar.left:has(.explorer)) {\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body.lock-scroll > :not(.sidebar.left:has(.explorer)) {\n transform: translateX(100dvw);\n transition: transform 300ms ease-in-out;\n }\n .page > #quartz-body .sidebar.left:has(.explorer) {\n box-sizing: border-box;\n position: sticky;\n background-color: var(--light);\n padding: 1rem 0 1rem 0;\n margin: 0;\n }\n .page > #quartz-body .hide-until-loaded ~ .explorer-content {\n display: none;\n }\n}\n.explorer {\n display: flex;\n flex-direction: column;\n overflow-y: hidden;\n min-height: 1.2rem;\n flex: 0 1 auto;\n}\n\n.explorer.collapsed {\n flex: 0 1 1.2rem;\n}\n\n.explorer.collapsed .fold {\n transform: rotateZ(-90deg);\n}\n\n.explorer .fold {\n margin-left: 0.5rem;\n transition: transform 0.3s ease;\n opacity: 0.8;\n}\n\n@media all and (max-width: 800px) {\n .explorer {\n order: -1;\n height: initial;\n overflow: hidden;\n flex-shrink: 0;\n align-self: flex-start;\n margin-top: auto;\n margin-bottom: auto;\n }\n}\n.explorer button.mobile-explorer {\n display: none;\n}\n\n.explorer button.desktop-explorer {\n display: flex;\n}\n\n@media all and (max-width: 800px) {\n .explorer button.mobile-explorer {\n display: flex;\n }\n .explorer button.desktop-explorer {\n display: none;\n }\n}\n.explorer svg {\n pointer-events: all;\n transition: transform 0.35s ease;\n}\n\n.explorer svg > polyline {\n pointer-events: none;\n}\n\nbutton.mobile-explorer,\nbutton.desktop-explorer {\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding: 0;\n color: var(--dark);\n display: flex;\n align-items: center;\n}\n\nbutton.mobile-explorer h2,\nbutton.desktop-explorer h2 {\n font-size: 1rem;\n display: inline-block;\n margin: 0;\n}\n\n.explorer-content {\n list-style: none;\n overflow: hidden;\n overflow-y: auto;\n margin-top: 0.5rem;\n}\n\n.explorer-content ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n.explorer-content ul.explorer-ul {\n overscroll-behavior: contain;\n}\n\n.explorer-content ul li > a {\n color: var(--dark);\n opacity: 0.75;\n pointer-events: all;\n}\n\n.explorer-content ul li > a.active {\n opacity: 1;\n color: var(--tertiary);\n}\n\n.explorer-content .folder-outer {\n visibility: collapse;\n display: grid;\n grid-template-rows: 0fr;\n transition-property: grid-template-rows, visibility;\n transition-duration: 0.3s;\n transition-timing-function: ease-in-out;\n}\n\n.explorer-content .folder-outer.open {\n visibility: visible;\n grid-template-rows: 1fr;\n}\n\n.explorer-content .folder-outer > ul {\n overflow: hidden;\n margin-left: 6px;\n padding-left: 0.8rem;\n border-left: 1px solid var(--lightgray);\n}\n\n.folder-container {\n flex-direction: row;\n display: flex;\n align-items: center;\n user-select: none;\n}\n\n.folder-container div > a {\n color: var(--secondary);\n font-family: var(--headerFont);\n font-size: 0.95rem;\n font-weight: 600;\n line-height: 1.5rem;\n display: inline-block;\n}\n\n.folder-container div > a:hover {\n color: var(--tertiary);\n}\n\n.folder-container div > button {\n color: var(--dark);\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding-left: 0;\n padding-right: 0;\n display: flex;\n align-items: center;\n font-family: var(--headerFont);\n}\n\n.folder-container div > button span {\n font-size: 0.95rem;\n display: inline-block;\n color: var(--secondary);\n font-weight: 600;\n margin: 0;\n line-height: 1.5rem;\n pointer-events: none;\n}\n\n.folder-icon {\n margin-right: 5px;\n color: var(--secondary);\n cursor: pointer;\n transition: transform 0.3s ease;\n backface-visibility: visible;\n flex-shrink: 0;\n}\n\nli:has(> .folder-outer:not(.open)) > .folder-container > svg {\n transform: rotate(-90deg);\n}\n\n.folder-icon:hover {\n color: var(--tertiary);\n}\n\n@media all and (max-width: 800px) {\n .explorer.collapsed {\n flex: 0 0 34px;\n }\n .explorer.collapsed > .explorer-content {\n transform: translateX(-100vw);\n visibility: hidden;\n }\n .explorer:not(.collapsed) {\n flex: 0 0 34px;\n }\n .explorer:not(.collapsed) > .explorer-content {\n transform: translateX(0);\n visibility: visible;\n }\n .explorer .explorer-content {\n box-sizing: border-box;\n z-index: 100;\n position: absolute;\n top: 0;\n left: 0;\n margin-top: 0;\n background-color: var(--light);\n max-width: 100vw;\n width: 100vw;\n transform: translateX(-100vw);\n transition: transform 200ms ease, visibility 200ms ease;\n overflow: hidden;\n padding: 4rem 0 2rem 0;\n height: 100dvh;\n max-height: 100dvh;\n visibility: hidden;\n }\n .explorer .mobile-explorer {\n margin: 0;\n padding: 5px;\n z-index: 101;\n }\n .explorer .mobile-explorer.hide-until-loaded {\n display: none;\n }\n .explorer .mobile-explorer .lucide-menu {\n stroke: var(--darkgray);\n }\n}\n@media all and (max-width: 800px) {\n .mobile-no-scroll .explorer-content > .explorer-ul {\n overscroll-behavior: contain;\n }\n}","var Tu=Object.hasOwnProperty;var X,A,Y,_u,S,G,uu,eu,tu,$,H,M,fu,O={},nu=[],du=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,j=Array.isArray;function y(u,e){for(var t in e)u[t]=e[t];return u}function J(u){u&&u.parentNode&&u.parentNode.removeChild(u)}function R(u,e,t,o,l){var r={type:u,props:e,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++Y,__i:-1,__u:0};return l==null&&A.vnode!=null&&A.vnode(r),r}function L(u){return u.children}function N(u,e){this.props=u,this.context=e}function w(u,e){if(e==null)return u.__?w(u.__,u.__i+1):null;for(var t;es&&S.sort(eu),u=S.shift(),s=S.length,u.__d&&(t=void 0,o=void 0,l=(o=(e=u).__v).__e,r=[],i=[],e.__P&&((t=y({},o)).__v=o.__v+1,A.vnode&&A.vnode(t),Du(e.__P,t,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,r,l??w(o),!!(32&o.__u),i),t.__v=o.__v,t.__.__k[t.__i]=t,Cu(r,t,i),o.__e=o.__=null,t.__e!=l&&ru(t)));W.__r=0}function ou(u,e,t,o,l,r,i,s,d,D,c){var n,p,F,_,E,C,a,f=o&&o.__k||nu,h=e.length;for(d=pu(t,e,f,d,h),n=0;n0?i=u.__k[r]=R(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):u.__k[r]=i,d=r+p,i.__=u,i.__b=u.__b+1,s=null,(D=i.__i=Eu(i,t,d,n))!=-1&&(n--,(s=t[D])&&(s.__u|=2)),s==null||s.__v==null?(D==-1&&(l>c?p--:ld?p--:p++,i.__u|=4))):u.__k[r]=null;if(n)for(r=0;r(c?1:0)){for(l=t-1,r=t+1;l>=0||r=0?l--:r++])!=null&&(2&D.__u)==0&&s==D.key&&d==D.type)return i}return-1}function Z(u,e,t){e[0]==\"-\"?u.setProperty(e,t??\"\"):u[e]=t==null?\"\":typeof t!=\"number\"||du.test(e)?t:t+\"px\"}function P(u,e,t,o,l){var r,i;u:if(e==\"style\")if(typeof t==\"string\")u.style.cssText=t;else{if(typeof o==\"string\"&&(u.style.cssText=o=\"\"),o)for(e in o)t&&e in t||Z(u.style,e,\"\");if(t)for(e in t)o&&t[e]==o[e]||Z(u.style,e,t[e])}else if(e[0]==\"o\"&&e[1]==\"n\")r=e!=(e=e.replace(tu,\"$1\")),i=e.toLowerCase(),e=i in u||e==\"onFocusOut\"||e==\"onFocusIn\"?i.slice(2):e.slice(2),u.l||(u.l={}),u.l[e+r]=t,t?o?t.u=o.u:(t.u=$,u.addEventListener(e,r?M:H,r)):u.removeEventListener(e,r?M:H,r);else{if(l==\"http://www.w3.org/2000/svg\")e=e.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(e!=\"width\"&&e!=\"height\"&&e!=\"href\"&&e!=\"list\"&&e!=\"form\"&&e!=\"tabIndex\"&&e!=\"download\"&&e!=\"rowSpan\"&&e!=\"colSpan\"&&e!=\"role\"&&e!=\"popover\"&&e in u)try{u[e]=t??\"\";break u}catch{}typeof t==\"function\"||(t==null||t===!1&&e[4]!=\"-\"?u.removeAttribute(e):u.setAttribute(e,e==\"popover\"&&t==1?\"\":t))}}function Q(u){return function(e){if(this.l){var t=this.l[e.type+u];if(e.t==null)e.t=$++;else if(e.t0?u:j(u)?u.map(iu):y({},u)}function hu(u,e,t,o,l,r,i,s,d){var D,c,n,p,F,_,E,C=t.props||O,a=e.props,f=e.type;if(f==\"svg\"?l=\"http://www.w3.org/2000/svg\":f==\"math\"?l=\"http://www.w3.org/1998/Math/MathML\":l||(l=\"http://www.w3.org/1999/xhtml\"),r!=null){for(D=0;Di.slugSegment===o);l||(l=this.makeChild(e,void 0));let r=(t.filePath||t.slug||\"\").split(\"/\");l.fileSegmentHint=r[r.length-e.length],l.insert(e.slice(1),t)}}add(e){this.insert(e.slug.split(\"/\"),e)}sort(e){this.children.sort(e),this.children.forEach(t=>t.sort(e))}filter(e){this.children=this.children.filter(e),this.children.forEach(t=>t.filter(e))}map(e){e(this),this.children.forEach(t=>t.map(e))}static fromEntries(e){let t=new u([],null);return e.forEach(([,o])=>t.add(o)),t}},yu=(u,e)=>!u.isFolder&&!e.isFolder||u.isFolder&&e.isFolder?u.displayName.localeCompare(e.displayName,void 0,{numeric:!0,sensitivity:\"base\"}):!u.isFolder&&e.isFolder?1:-1,xu=u=>u.slugSegment!==\"tags\";function Su(u,e,t,o){return t&&u.filter(t),o&&u.map(o),e&&u.sort(e),u}async function bu(u){try{console.log(\"[Explorer] Fetching content index...\");let t=await(await fetch(\"/static/contentIndex.json\")).json();if(console.log(\"[Explorer] Fetched data keys:\",Object.keys(t).slice(0,5)),!t)return console.error(\"[Explorer] No data received\"),null;let o=t.content||t,l=Object.entries(o);if(console.log(\"[Explorer] Entry count:\",l.length),l.length===0)return console.warn(\"[Explorer] No content entries found\"),null;let r=V.fromEntries(l);console.log(\"[Explorer] Trie root children:\",r.children.length);let i=yu,s=xu,d=null;if(u)try{let D=JSON.parse(u);D.sortFn&&(i=new Function(\"a\",\"b\",\"return (\"+D.sortFn+\")(a, b)\")),D.filterFn&&(s=new Function(\"node\",\"return (\"+D.filterFn+\")(node)\")),D.mapFn&&(d=new Function(\"node\",\"(\"+D.mapFn+\")(node)\"))}catch(D){console.error(\"Error parsing data functions:\",D)}return Su(r,i,s,d)}catch(e){return console.error(\"Error building file trie:\",e),null}}var Fu=0;function cu(u,e,t,o,l,r=\"\"){let i=document.getElementById(\"template-folder\"),s=document.getElementById(\"template-file\");if(!i||!s)return;let d=r?r+\"/\"+u.slugSegment:u.slugSegment,D=I(t);if(u.isFolder){let c=i.content.cloneNode(!0),n=c.querySelector(\".folder-container\"),p=c.querySelector(\".folder-button\"),F=c.querySelector(\".folder-title\"),_=c.querySelector(\".folder-outer\"),E=c.querySelector(\".content\");if(F&&(F.textContent=u.displayName||u.slugSegment),n&&(n.dataset.folderpath=u.slug),o===\"link\"&&p){let h=document.createElement(\"a\");h.className=p.className;let g=I(u.slug);h.href=\"/\"+(g||\"\"),F?h.appendChild(F):h.textContent=u.displayName||u.slugSegment,p.replaceWith(h),p=h}let C=l[u.slug]!==void 0?l[u.slug]:!0,a=I(u.slug),f=a&&a===D.slice(0,a.length);if((!C||f)&&_&&_.classList.add(\"open\"),u.children&&u.children.length>0&&E)for(let h of u.children)cu(h,E,t,o,l,d);e.appendChild(c)}else if(u.data){let c=s.content.cloneNode(!0),n=c.querySelector(\"a\");n&&(n.href=\"/\"+u.data.slug,n.textContent=u.displayName||u.slugSegment,u.data.slug===t&&n.classList.add(\"active\")),e.appendChild(c)}}async function au(u){let e=++Fu;try{console.log(\"[Explorer] Nav event received, generation:\",e);let t=(u.detail?.url||\"\").replace(/^\\/+/,\"\"),o=document.querySelectorAll(\"div.explorer\");console.log(\"[Explorer] Found\",o.length,\"explorers\");let l={};try{JSON.parse(localStorage.getItem(\"fileTree\")||\"[]\").forEach(i=>{l[i.path]=i.collapsed})}catch(r){console.error(\"[Explorer] Error loading saved state:\",r)}for(let r of o){let i=r.querySelector(\".explorer-ul\");if(!i){console.warn(\"[Explorer] No explorer-ul found\");continue}i.innerHTML='
  • ';let s=r.dataset.dataFns,d=r.dataset.behavior||\"collapse\";console.log(\"[Explorer] Starting tree build...\");let D=await bu(s);if(e===Fu){if(console.log(\"[Explorer] Render generation is current, rendering tree\"),console.log(\"[Explorer] Trie result:\",D?\"success\":\"null\"),D&&D.children&&D.children.length>0){i.innerHTML='
  • ',console.log(\"[Explorer] Rendering\",D.children.length,\"children\");for(let E of D.children)cu(E,i,t,d,l,\"\");console.log(\"[Explorer] Render complete, final list length:\",i.children.length)}else console.warn(\"[Explorer] No trie or empty children\");let _=sessionStorage.getItem(\"explorerScrollTop\");if(_)i.scrollTop=parseInt(_,10);else{let E=i.querySelector(\".active\");E&&E.scrollIntoView({behavior:\"smooth\"})}}else console.log(\"[Explorer] Stale render generation, skipping tree render\");let c=[],n=r.getElementsByClassName(\"explorer-toggle\");for(let _ of n){let E=function(){let C=this.closest(\".explorer\");if(!C)return;let a=C.classList.toggle(\"collapsed\");C.setAttribute(\"aria-expanded\",a?\"false\":\"true\"),a?document.documentElement.classList.remove(\"mobile-no-scroll\"):document.documentElement.classList.add(\"mobile-no-scroll\")};_.addEventListener(\"click\",E),c.push(()=>_.removeEventListener(\"click\",E))}let p=r.getElementsByClassName(\"folder-icon\");for(let _ of p){let E=function(C){C.stopPropagation();let a=this.parentElement;if(!a)return;let f=a.nextElementSibling;if(!f)return;f.classList.toggle(\"open\");let h=!f.classList.contains(\"open\"),g=a.dataset.folderpath,B=JSON.parse(localStorage.getItem(\"fileTree\")||\"[]\"),m=B.findIndex(x=>x.path===g);m>=0?B[m].collapsed=h:B.push({path:g,collapsed:h}),localStorage.setItem(\"fileTree\",JSON.stringify(B))};_.addEventListener(\"click\",E),c.push(()=>_.removeEventListener(\"click\",E))}let F=r.getElementsByClassName(\"folder-button\");for(let _ of F){let E=function(C){let a=this.closest(\".folder-container\");if(!a)return;let f=r.dataset.behavior||\"collapse\",h=a.nextElementSibling,g=a.dataset.folderpath;if(f!==\"link\"){if(C.stopPropagation(),!h)return;h.classList.toggle(\"open\");let B=!h.classList.contains(\"open\"),m=JSON.parse(localStorage.getItem(\"fileTree\")||\"[]\"),x=m.findIndex(b=>b.path===g);x>=0?m[x].collapsed=B:m.push({path:g,collapsed:B}),localStorage.setItem(\"fileTree\",JSON.stringify(m))}};_.addEventListener(\"click\",E),c.push(()=>_.removeEventListener(\"click\",E))}typeof window<\"u\"&&window.addCleanup&&window.addCleanup(()=>c.forEach(_=>_()))}for(let r of document.getElementsByClassName(\"explorer\")){let i=r.querySelector(\".mobile-explorer\");i&&(i.classList.remove(\"hide-until-loaded\"),i.checkVisibility&&i.checkVisibility()&&(r.classList.add(\"collapsed\"),r.setAttribute(\"aria-expanded\",\"false\"),document.documentElement.classList.remove(\"mobile-no-scroll\")))}}catch(t){console.error(\"[Explorer] Fatal error in nav handler:\",t)}}document.addEventListener(\"nav\",au);document.addEventListener(\"render\",au);document.addEventListener(\"prenav\",()=>{let u=document.querySelector(\".explorer-ul\");u&&sessionStorage.setItem(\"explorerScrollTop\",u.scrollTop.toString())});\n","import type {\n QuartzComponent,\n QuartzComponentConstructor,\n QuartzComponentProps,\n} from \"@quartz-community/types\";\nimport OverflowListFactory from \"./OverflowList\";\nimport { classNames } from \"../util/lang\";\nimport { i18n } from \"../i18n\";\nimport style from \"./styles/explorer.scss\";\n// @ts-expect-error - Inline script loaded as text by esbuild plugin\nimport script from \"./scripts/explorer.inline.ts\";\n\ninterface FileTrieNode {\n slugSegment?: string;\n slugSegments?: string[];\n displayName?: string;\n isFolder: boolean;\n data: Record | null;\n children: FileTrieNode[];\n}\n\nexport interface ExplorerOptions {\n title?: string;\n folderDefaultState: \"collapsed\" | \"open\";\n folderClickBehavior: \"collapse\" | \"link\";\n useSavedState: boolean;\n sortFn?: (a: FileTrieNode, b: FileTrieNode) => number;\n filterFn?: (node: FileTrieNode) => boolean;\n mapFn?: (node: FileTrieNode) => FileTrieNode;\n order?: Array<\"filter\" | \"map\" | \"sort\">;\n}\n\nconst defaultOptions: ExplorerOptions = {\n folderDefaultState: \"collapsed\",\n folderClickBehavior: \"link\",\n useSavedState: true,\n mapFn: (node: FileTrieNode) => {\n return node;\n },\n sortFn: (a: FileTrieNode, b: FileTrieNode) => {\n if ((!a.isFolder && !b.isFolder) || (a.isFolder && b.isFolder)) {\n return (a.displayName || \"\").localeCompare(b.displayName || \"\", undefined, {\n numeric: true,\n sensitivity: \"base\",\n });\n }\n\n if (!a.isFolder && b.isFolder) {\n return 1;\n }\n return -1;\n },\n filterFn: (node: FileTrieNode) => node.slugSegment !== \"tags\",\n order: [\"filter\", \"map\", \"sort\"],\n};\n\nlet numExplorers = 0;\n\nfunction concatenateResources(...resources: (string | undefined)[]): string {\n return resources.filter((r): r is string => !!r).join(\"\\n\");\n}\n\nexport default ((userOpts?: Partial) => {\n const opts: ExplorerOptions = { ...defaultOptions, ...userOpts };\n const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory();\n\n const ExplorerComponent: QuartzComponent = (props: QuartzComponentProps) => {\n const { cfg } = props;\n const displayClass = (props as { displayClass?: \"mobile-only\" | \"desktop-only\" }).displayClass;\n const id = `explorer-${numExplorers++}`;\n const locale = cfg?.locale ?? \"en-US\";\n\n const title = opts.title ?? i18n(locale).components.explorer.title;\n\n return (\n \n \n \n \n \n \n \n \n \n

    {title}

    \n \n \n \n \n
    \n \n
    \n \n \n \n );\n };\n\n ExplorerComponent.css = style;\n ExplorerComponent.afterDOMLoaded = concatenateResources(script, overflowListAfterDOMLoaded);\n return ExplorerComponent;\n}) satisfies QuartzComponentConstructor;\n"]} \ No newline at end of file diff --git a/dist/types.d.ts b/dist/types.d.ts new file mode 100644 index 0000000..c2903f8 --- /dev/null +++ b/dist/types.d.ts @@ -0,0 +1,42 @@ +export { BuildCtx, CSSResource, ChangeEvent, JSResource, ProcessedContent, QuartzEmitterPlugin, QuartzEmitterPluginInstance, QuartzFilterPlugin, QuartzFilterPluginInstance, QuartzPluginData, QuartzTransformerPlugin, QuartzTransformerPluginInstance, StaticResources } from '@quartz-community/types'; + +interface ExampleTransformerOptions { + /** Token used to highlight text, defaults to ==highlight== */ + highlightToken: string; + /** Add a CSS class to all headings in the rendered HTML. */ + headingClass: string; + /** Enable remark-gfm for tables/task lists. */ + enableGfm: boolean; + /** Enable adding slug IDs to headings. */ + addHeadingSlugs: boolean; +} +interface ExampleFilterOptions { + /** Allow pages marked draft: true to publish. */ + allowDrafts: boolean; + /** Exclude pages that contain any of these frontmatter tags. */ + excludeTags: string[]; + /** Exclude paths that start with any of these prefixes (relative to content root). */ + excludePathPrefixes: string[]; +} +interface ExampleEmitterOptions { + /** Filename to emit at the site root. */ + manifestSlug: string; + /** Whether to include the frontmatter block in the manifest. */ + includeFrontmatter: boolean; + /** Extra metadata to write at the top level of the manifest. */ + metadata: Record; + /** Optional hook to transform the emitted manifest JSON string. */ + transformManifest?: (json: string) => string; + /** Add a custom class to the emitted manifest