Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

runtime fetch versions

+29 -12
+29 -12
docs/src/components/Versions.astro
··· 1 1 --- 2 - const versions = await fetch('https://den.oeiuwq.com/versions.json').then(r => r.json()).catch(e => []); 3 2 --- 4 3 5 - { 6 - versions.length > 0 && <select id="versions"> 7 - <option value="/">main</option> 8 - {versions.map(v => <option value={"/"+v.name.replace("docs-","")}>{v.name.replace("docs-","")}</option>)} 9 - </select> 10 - } 4 + <den-version-select /> 11 5 12 6 <script> 13 - const versions = document.getElementById("versions"); 14 - if (versions != null) { 15 - versions.addEventListener("change", _ => { document.location.pathname = versions.value; }); 16 - Array.from(versions.options).forEach(opt => document.location.pathname.startsWith(opt.value) && opt.selected = "selected"); 17 - } 7 + class DenVersionSelect extends HTMLElement { 8 + constructor() { 9 + super(); 10 + const sel = document.createElement("select"); 11 + 12 + const init = () => { 13 + this.appendChild(sel); 14 + sel.addEventListener("change", _ => { document.location.pathname = sel.value; }); 15 + addVersion("main"); 16 + }; 17 + 18 + const addVersion = version => { 19 + const name = version.replace("docs-", ""); 20 + const value = (name === "main") ? "/" : "/"+name; 21 + const opt = document.createElement("option"); 22 + opt.selected = document.location.pathname.startsWith(value); 23 + opt.value = value; 24 + opt.innerHTML = name; 25 + sel.appendChild(opt); 26 + }; 27 + 28 + fetch('https://den.oeiuwq.com/versions.json') 29 + .then(r => r.json()).catch(e => []) 30 + .then(r => { init(); return r.map(v => v.name) }) 31 + .then(r => r.forEach(addVersion)); 32 + } 33 + }; 34 + customElements.define('den-version-select', DenVersionSelect); 18 35 </script>