Creating nested menu from directory with Nodejs

I would like to create a nested menu and show all files and directories (except hidden folders) in the selected directory with#nodejs

import {readdir} from 'node:fs/promises';
import {join, parse} from 'node:path';
import slugify from '@sindresorhus/slugify';  

export async function directoryMenu(dir) {  
 let menu = '';  
 for (const child of await readdir(dir, {withFileTypes: true})) {  
  if (!'.') && !'_')) {  
   if (child.isDirectory()) {  
    menu += `<li><button>${}</button> ${await directoryMenu(dir + '/' +}</li>`;  
   } else if (child.isFile() &&\.md$/)) {  
    const name = parse(;  
    const href = join(dir.replace(/^content\/?/, '/').toLowerCase(), slugify(name));  
    menu += `<li><a href="${href}">${name}</a></li>`;  
 return `<ul>${menu}</ul>`;  

You can try it:

console.log(await directoryMenu('content'));