import { error } from '@sveltejs/kit';
import { templates } from '$lib/templates/templates';

/** @type {import('./$types').PageLoad} */
export function load(event) {

  /** @type {string} */
  const slug = event.params.slug;

	/** @type {number} */ const templateIndex = templates.map((e) => e.name).indexOf(slug);
  /** @type {string} */ const templateImage = templates[templateIndex].image;
  if (templateIndex !== -1) {
    return {
      slug,
      templateIndex,
      templateImage
    }
  }

  throw error(404, "Not found");
}
