Mercurial Hosting > arkian
diff src/site.js @ 0:45a3989c3447
start public repo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 11 Sep 2025 15:26:39 -0600 |
parents | |
children | 38e5ff291f96 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/site.js Thu Sep 11 15:26:39 2025 -0600 @@ -0,0 +1,53 @@ +'use strict'; + +function head() { + document.write(`\ + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style> + @import "/site.css"; + </style> +` ); +} + +function header() { + document.write(`\ + <div header> + <span breadcrumbs> + <a href="/">Arkian</a> + </span> + <span>by <a href="https://linkmy.style/fschmidt">fschmidt</a></span> + </div> +` ); +} + +function showToc(content) { + document.writeln('<ul>'); + for( let id in content ) { + let info = content[id]; + document.writeln(`<li><a id="c_${id}" href="#${id}">${info.title}</a>`); + let subs = info.subs; + if( subs ) { + showToc(subs); + } + document.writeln('</li>'); + } + document.writeln('</ul>'); +} + +function showContent(content,h) { + for( let id in content ) { + let info = content[id]; + document.write(`\ + <div heading> + <h${h}><a id="${id}" href="#${id}">${info.title}</a></h${h}> + <a href="#c_${id}">contents</a> + </div> +` ); + if( info.content ) + document.write(info.content); + let subs = info.subs; + if( subs ) { + showContent(subs,h+1) + } + } +}