All checks were successful
Deploy production / deploy (push) Successful in 2m24s
24 lines
910 B
TypeScript
24 lines
910 B
TypeScript
import { carOverview, PAGE_SIZE, parseFilters, searchCars } from '#lib/server/cars.js';
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
export const load: PageServerLoad = async ({ url }) => {
|
|
const filters = parseFilters(url.searchParams);
|
|
const [{ cars, total }, overview] = await Promise.all([searchCars(filters), carOverview()]);
|
|
return {
|
|
filters,
|
|
cars,
|
|
total,
|
|
pageSize: PAGE_SIZE,
|
|
brands: overview.brands.map(({ slug, name, models }) => ({ slug, name, models })),
|
|
topBrands: overview.byNl
|
|
.slice(0, 16)
|
|
.map(({ slug, name, models, nlCount, logo }) => ({ slug, name, models, nlCount, logo })),
|
|
stats: overview.stats,
|
|
currentYear: new Date().getFullYear(),
|
|
seo: {
|
|
title: 'Car pokedex',
|
|
description: `Search ${overview.stats.models.toLocaleString('en-GB')} car models from ${overview.stats.brands} brands, with Dutch registration data and US fuel economy specs.`
|
|
}
|
|
};
|
|
};
|