import { error } from '@sveltejs/kit';
import { locationsBySlug } from '$lib/content/locations';
import { getSharedPageContent } from '$lib/server/content';
import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async ({ params }) => {
  const location = locationsBySlug[params.suburb];

  if (!location) {
    throw error(404, 'Page not found');
  }

  return {
    content: await getSharedPageContent(),
    location
  };
}
