import type { RequestEvent, RequestHandler } from './$types'
import {json} from '@sveltejs/kit'
import  home_content from "$lib/data/content/home.html?raw"
import  about_content from "$lib/data/content/about.html?raw"
import  qualifying_content from "$lib/data/content/qualifying.html?raw"
import  competitive_content from "$lib/data/content/competitive.html?raw"
export const GET: RequestHandler = async ({url}: RequestEvent) => {
    let content = ""
    let image = undefined
    const page= url.searchParams.get("page") ?? 'nopage'
    switch (page) {
        case "home":
            content = home_content
            image = "/images/pattern.png"
            break;
        case "qualifying":
            content = qualifying_content            
            break;
        case "competitive":
            content = competitive_content            
            break;
        case "about":
            content = about_content            
            break;
        default:
            break;
    }
    //slience error just send empty content if not found
    if(!content)
        console.log(`Request content ${page} not found`)
    return json({content,image})

}