import fs from 'node:fs'

type section  = {
    title : string;
    href?: string;
    content?: string;
}

let sections = <section[]>[
    {title : "home", href: "#home"},
    {title : "bio", href: "#bio"},
    {title : "musique", href: "#musique"},
    {title : "vidéos", href: "https://videos.cassidypunchmachine.com/c/cassidy/videos"},
    {title : "artworks", href: "#artworks"},
    {title : "live", href: "#live"},
    {title : "contact", href: "#contact"},

]

//feed section with html contents only if ${title}.html file exists
sections.map((s) => {
    let path = `./server/api/${s.title}.html`
    if(fs.existsSync(path))
        s.content = fs.readFileSync(path,{encoding:'utf8', flag:'r'});
})



export default defineEventHandler((event) => {  
        return {    
            sections : sections
        }
    }
)