From 63644ecc7f2a00c3d32ce88d0e2a75fed4d64419 Mon Sep 17 00:00:00 2001 From: Snorre Ettrup Altschul Date: Fri, 7 Feb 2025 00:45:54 +0100 Subject: [PATCH] did some more mining off camera also posts can be hidden by prepending a _ --- public/js/md2html.js | 31 ++++++++++++++++++- .../post.md | 14 ++++----- .../post.md | 8 +++-- public/posts/{test.md => _test.md} | 0 public/posts/_toc.md | 17 ++++++++++ public/posts/index.html | 6 ++++ public/posts/toc.md | 5 --- src/main.rs | 2 ++ 8 files changed, 67 insertions(+), 16 deletions(-) rename public/posts/{test.md => _test.md} (100%) create mode 100644 public/posts/_toc.md delete mode 100644 public/posts/toc.md diff --git a/public/js/md2html.js b/public/js/md2html.js index a925dcf..2fbd18c 100644 --- a/public/js/md2html.js +++ b/public/js/md2html.js @@ -284,7 +284,36 @@ const tokens2html = (tokens, title) => { for (let token of tokens) { switch (token.type) { case "toc": - output += "TABLE LE CONTENTOS" + let headers = tokens.filter(x => x.type == "header"); + + let listHTML = ''; + let currentLevel = 0; + + headers.forEach(header => { + let indent = ' '.repeat(header.level - 1); // Indentation based on header level + + // Check if we need to create a new