mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
24 lines
542 B
TypeScript
24 lines
542 B
TypeScript
import { error } from '@sveltejs/kit';
|
|
import type { PageLoad } from './$types';
|
|
|
|
import { svgs } from '@/data/svgs';
|
|
import type { iSVG } from '@/types/svg';
|
|
|
|
export const load = (async ({ params }) => {
|
|
const { slug } = params;
|
|
|
|
// Check if slug is valid:
|
|
if (!slug) {
|
|
return error(404, 'Not found');
|
|
}
|
|
|
|
// Filter out the svg with the matching slug:
|
|
const svgsByCategory = svgs.filter((svg: iSVG) => svg.category.toLowerCase() === slug);
|
|
|
|
return {
|
|
props: {
|
|
svgs: svgsByCategory
|
|
}
|
|
};
|
|
}) satisfies PageLoad;
|