+ <div id="sitemap-container"><input type="text" id="sitemap-search" placeholder="Search pages..." style="width:100%;padding:8px;margin-bottom:16px;box-sizing:border-box;font-size:16px;" /><div id="sitemap-results"></div></div><script>var pages = [{"url":"/blog/markdown-tips/","title":"Markdown Tips and Tricks","description":"Power user tips for writing great content in Agave","filename":"markdown-tips"},{"url":"/blog/deploying/","title":"Deploying Your Agave Site","description":"How to deploy your static site to GitHub Pages, Netlify, or any host","filename":"deploying"},{"url":"/blog/getting-started/","title":"Getting Started with Agave","description":"A beginner's guide to building your first static site with Agave","filename":"getting-started"},{"url":"/blog/","title":"Blog","description":"Latest posts from the Agave blog","filename":"index"},{"url":"/contact/","title":"Contact Us","description":"Get in touch with the Agave team","filename":"contact"},{"url":"/","title":"Agave Test Site","description":"A demo site built with Agave static site generator","filename":"index"},{"url":"/about/","title":"About Agave","description":"Agave is a simple static site generator written in ReasonML","filename":"about"}];var input = document.getElementById('sitemap-search');var results = document.getElementById('sitemap-results');function buildTree(items) { var root = { children: {}, pages: [] }; items.forEach(function(p) { var parts = p.url.replace(/^\/+|\/+$/g, '').split('/').filter(function(s) { return s.length > 0; }); if (parts.length === 0) { root.pages.push(p); } else { var node = root; for (var i = 0; i < parts.length - 1; i++) { if (!node.children[parts[i]]) { node.children[parts[i]] = { children: {}, pages: [], key: parts[i] }; } node = node.children[parts[i]]; } node.pages.push(p); } }); return root;}function renderTree(node, container) { var ul = document.createElement('ul'); ul.style.listStyle = 'none'; ul.style.paddingLeft = container === results ? '0' : '20px'; var sortedPages = node.pages.slice().sort(function(a, b) { return a.title.toLowerCase().localeCompare(b.title.toLowerCase()); }); sortedPages.forEach(function(p) { var li = document.createElement('li'); li.style.marginBottom = '8px'; li.innerHTML = '<a href="' + p.url + '">' + p.title + '</a>' + (p.description ? '<br/><small>' + p.description + '</small>' : ''); ul.appendChild(li); }); var keys = Object.keys(node.children).sort(function(a, b) { var aNode = node.children[a]; var bNode = node.children[b]; var aLabel = aNode.pages.length > 0 ? aNode.pages[0].title : a; var bLabel = bNode.pages.length > 0 ? bNode.pages[0].title : b; return aLabel.toLowerCase().localeCompare(bLabel.toLowerCase()); }); keys.forEach(function(k) { var child = node.children[k]; var li = document.createElement('li'); li.style.marginBottom = '8px'; li.style.marginTop = '12px'; var label = k.charAt(0).toUpperCase() + k.slice(1).replace(/-/g, ' '); li.innerHTML = '<strong>' + label + '</strong>'; ul.appendChild(li); renderTree(child, li); }); container.appendChild(ul);}function renderFlat(items) { var ul = document.createElement('ul'); ul.style.listStyle = 'none'; ul.style.paddingLeft = '0'; items.sort(function(a, b) { return a.title.toLowerCase().localeCompare(b.title.toLowerCase()); }).forEach(function(p) { var li = document.createElement('li'); li.style.marginBottom = '8px'; li.innerHTML = '<a href="' + p.url + '">' + p.title + '</a>' + (p.description ? '<br/><small>' + p.description + '</small>' : ''); ul.appendChild(li); }); results.appendChild(ul);}function render(filter) { var q = filter.toLowerCase(); results.innerHTML = ''; if (q) { var matched = pages.filter(function(p) { return p.title.toLowerCase().indexOf(q) !== -1 || p.description.toLowerCase().indexOf(q) !== -1 || p.filename.toLowerCase().indexOf(q) !== -1; }); renderFlat(matched); } else { var tree = buildTree(pages); renderTree(tree, results); }}input.addEventListener('input', function() { render(this.value); });render('');</script>
0 commit comments