{ "version": 3, "sources": ["../../../src/js/modules/table-of-contents.js"], "sourcesContent": ["document.addEventListener('DOMContentLoaded', () => {\n\tconst post_content = document.querySelector('section.post-content .content')\n\tconst toc = document.querySelector('section.post-content .sidebar .toc')\n\tconst headings = post_content?.querySelectorAll('h2.wp-block-heading')\n\n\tif (headings) {\n\t\tlet title = document.createElement('h6')\n\t\ttitle.innerText = 'Table of Contents'\n\t\ttoc.appendChild(title)\n\n\t\tlet list = document.createElement('ul')\n\n\t\theadings.forEach(h => {\n\t\t\tif (!h.id) {\n\t\t\t\t// If no id, create one from the title content\n\t\t\t\tlet new_id = encodeURIComponent(h.innerText)\n\t\t\t\th.setAttribute('id', new_id)\n\t\t\t}\n\n\t\t\tlet li = document.createElement('li')\n\t\t\tlet anchor = document.createElement('a')\n\t\t\tanchor.setAttribute('href', `#${h.id}`)\n\t\t\tanchor.innerText = h.innerText\n\t\t\tli.appendChild(anchor)\n\t\t\tlist.appendChild(li)\n\t\t})\n\n\t\ttoc.appendChild(list)\n\t}\n})\n"], "mappings": "mBAAA,SAAS,iBAAiB,mBAAoB,IAAM,CACnD,IAAMA,EAAe,SAAS,cAAc,+BAA+B,EACrEC,EAAM,SAAS,cAAc,oCAAoC,EACjEC,EAAWF,GAAA,YAAAA,EAAc,iBAAiB,uBAEhD,GAAIE,EAAU,CACb,IAAIC,EAAQ,SAAS,cAAc,IAAI,EACvCA,EAAM,UAAY,oBAClBF,EAAI,YAAYE,CAAK,EAErB,IAAIC,EAAO,SAAS,cAAc,IAAI,EAEtCF,EAAS,QAAQG,GAAK,CACrB,GAAI,CAACA,EAAE,GAAI,CAEV,IAAIC,EAAS,mBAAmBD,EAAE,SAAS,EAC3CA,EAAE,aAAa,KAAMC,CAAM,EAG5B,IAAIC,EAAK,SAAS,cAAc,IAAI,EAChCC,EAAS,SAAS,cAAc,GAAG,EACvCA,EAAO,aAAa,OAAQ,IAAIH,EAAE,IAAI,EACtCG,EAAO,UAAYH,EAAE,UACrBE,EAAG,YAAYC,CAAM,EACrBJ,EAAK,YAAYG,CAAE,CACpB,CAAC,EAEDN,EAAI,YAAYG,CAAI,EAEtB,CAAC", "names": ["post_content", "toc", "headings", "title", "list", "h", "new_id", "li", "anchor"] }