UNPKG

agahi

Version:

Client-side engine that renders Markdown files as a docs site in the browser—no build step.

2 lines (1 loc) 6.07 kB
!function(){"use strict";const n={name:"Agahi.js",repo:"teneplaysofficial/agahi",el:"app",edit:!0,editPath:"https://github.com/teneplaysofficial/agahi/edit/main/docs",editLabel:"Edit this page",showFooter:!0,showSearch:!0,searchPlaceholder:"Search...",defaultRoute:"",tocHeadings:["h2","h3"],tocLabel:"Table of Contents",scrollThreshold:300,..."undefined"!=typeof window&&window.$agahi||{}};!function(n,e){void 0===e&&(e={});var t=e.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===t&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n))}}("/* TOC Layout */\nmain {\n display: grid;\n grid-template-areas:\n 'md toc'\n 'page-actions toc';\n grid-template-columns: 1fr 15.625rem;\n grid-template-rows: 1fr auto;\n align-items: start;\n min-height: 0;\n}\n#md {\n grid-area: md;\n}\n#toc {\n grid-area: toc;\n position: sticky;\n top: var(--header-height);\n align-self: start;\n max-height: calc(100vh - var(--header-height));\n overflow-y: auto;\n border-left: 0.125rem solid var(--border-color);\n z-index: 50;\n}\n#page-actions {\n grid-area: page-actions;\n}\n/* TOC Title */\n#toc-title {\n padding: 0.75rem 0.5rem;\n text-align: left;\n border-bottom: 0.125rem solid var(--border-color);\n}\n/* TOC Navigation */\n#toc-nav {\n padding-left: 0.625rem;\n overflow-y: auto;\n max-height: 100%;\n margin-top: 0.75rem;\n}\n#toc-nav ul {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n#toc-nav li {\n position: relative;\n margin: 0.35rem 0;\n padding-left: 1rem;\n font-size: 0.95rem;\n line-height: 1.4;\n transition: color 0.2s ease;\n}\n#toc-nav li::before {\n content: '•';\n position: absolute;\n left: 0;\n font-weight: bold;\n font-size: 1rem;\n line-height: 1.2;\n color: #3b82f6;\n color: var(--primary-color, #3b82f6);\n}\n#toc-nav a {\n color: inherit;\n -webkit-text-decoration: none;\n text-decoration: none;\n transition: color 0.2s ease;\n}\n#toc-nav a:hover {\n color: #2563eb;\n color: var(--primary-color, #2563eb);\n -webkit-text-decoration: underline;\n text-decoration: underline;\n}\n/* Nested TOC */\n#toc-nav ul ul {\n padding-left: 1.25rem;\n margin-top: 0.3rem;\n}\n#toc-nav ul ul li::before {\n content: '◦';\n color: #9ca3af;\n}\n.chevron-arrow {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 0.9em;\n height: 0.9em;\n vertical-align: middle;\n visibility: hidden;\n}\n.chevron-arrow svg {\n display: block;\n width: 100%;\n height: 100%;\n transition: transform 0.3s ease;\n}\n/* Responsive Layout */\n@media (max-width: 1100px) {\n main {\n grid-template-areas:\n 'toc'\n 'md'\n 'page-actions';\n grid-template-columns: 1fr;\n grid-template-rows: auto 1fr auto;\n }\n\n #toc {\n position: inherit;\n border-left: none;\n }\n\n #toc-title {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n #toc-nav {\n max-height: 0;\n background: var(--background-hover);\n margin-top: 0;\n transition: max-height 0.3s ease;\n }\n\n #toc.collapsed #toc-nav {\n max-height: 0;\n }\n\n #toc.expanded #toc-nav {\n max-height: 75vh;\n }\n\n #toc.expanded .chevron-arrow svg {\n transform: rotate(180deg);\n }\n\n .chevron-arrow {\n visibility: visible;\n }\n}\n"),document.addEventListener("agahi:ready",(()=>{const e=document.getElementById("md");if(!e)return void console.error('[Agahi] Article element with id="md" not found.');if(!document.getElementById("toc")){const n=document.createElement("div");n.innerHTML='<div id="toc">\n <h2 id="toc-title">\n <span id="label"></span>\n <span class="chevron-arrow"\n ><svg\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n stroke="currentColor"\n stroke-width="2"\n stroke-linecap="round"\n stroke-linejoin="round"\n class="lucide lucide-chevron-down-icon lucide-chevron-down"\n >\n <path d="m6 9 6 6 6-6" />\n </svg>\n </span>\n </h2>\n <nav id="toc-nav">\n <ul></ul>\n </nav>\n</div>\n',e.parentNode.insertBefore(n.firstElementChild,e)}if(n.tocLabel){document.querySelector("#toc-title #label").textContent=n.tocLabel}new MutationObserver((()=>{const t=document.getElementById("toc"),o=t?.querySelector("nav > ul");if(!o)return;o.innerHTML="";const i=e.querySelectorAll(n.tocHeadings.join(", "));if(0===i.length){const n=document.createElement("li");return n.classList.add("toc-empty"),n.textContent="Nothing to show",void o.appendChild(n)}const a=[{level:0,list:o}];i.forEach((n=>{const e=parseInt(n.tagName[1],10);if(isNaN(e)||e<1||e>6)return;const t=document.createElement("li"),o=document.createElement("a");for(o.href=`?id=${n.id}`,o.textContent=n.textContent||`Untitled ${n.tagName}`,t.appendChild(o);a.length&&a[a.length-1].level>=e;)a.pop();a[a.length-1].list.appendChild(t);const i=document.createElement("ul");t.appendChild(i),a.push({level:e,list:i}),o.addEventListener("click",(e=>{e.preventDefault(),(n=>{const e=window.location.hash||"#/",[t,o=""]=e.slice(1).split("?"),i=new URLSearchParams(o);Object.entries(n).forEach((([n,e])=>{null===e?i.delete(n):i.set(n,e)}));const a=`#/${t.replace(/^\/+/,"")}${i.toString()?"?"+i.toString():""}`;window.history.replaceState({},"",a)})({id:n.id}),n.scrollIntoView({behavior:"smooth",block:"start"})}))}));const r=(n=>{const e=window.location.hash||"#/",[,t=""]=e.split("?");return new URLSearchParams(t).get(n)})("id");if(r){const n=document.getElementById(r);n&&setTimeout((()=>{n.scrollIntoView({behavior:"smooth",block:"start"})}),200)}})).observe(e,{childList:!0,subtree:!0}),document.getElementById("toc-title").addEventListener("click",(function(){const n=document.getElementById("toc");n.classList.toggle("expanded"),n.classList.toggle("collapsed")}))}))}();