if empty?(pages) "This page will either list your wiki pages or display your `index.md` (if it exists)." else map := {} for page in pages parts := split(page.name, '/') final := pop(parts) target := map for part in parts part = "{part}/" if !target[part] then target[part] = {} target = target[part] target[final] = page def print-nested(x) for k, v in x if type(v) == 'Page' split(v.title, '/')[-1] else puts("{k}") print-nested(v) puts("") print-nested(map)