feat: Initialize SvelteKit project, add tsconfig.json, and introduce a new Calculator.svelte component.
This commit is contained in:
21
hdyc-svelte/src/routes/category/[category]/+page.server.ts
Normal file
21
hdyc-svelte/src/routes/category/[category]/+page.server.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getCalculatorsByCategory, categories } from '$lib/data/calculators';
|
||||
|
||||
export const load: PageServerLoad = ({ params }) => {
|
||||
const cat = params.category;
|
||||
const meta = categories[cat];
|
||||
|
||||
if (!meta) {
|
||||
throw error(404, { message: `Category "${cat}" not found` });
|
||||
}
|
||||
|
||||
const calcs = getCalculatorsByCategory(cat);
|
||||
|
||||
return {
|
||||
category: cat,
|
||||
label: meta.label,
|
||||
icon: meta.icon,
|
||||
calculators: calcs
|
||||
};
|
||||
};
|
||||
30
hdyc-svelte/src/routes/category/[category]/+page.svelte
Normal file
30
hdyc-svelte/src/routes/category/[category]/+page.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{data.label} Converters — HowDoYouConvert.com</title>
|
||||
<meta name="description" content="Browse all {data.label.toLowerCase()} unit converters. Free online calculators for converting between {data.label.toLowerCase()} units." />
|
||||
</svelte:head>
|
||||
|
||||
<nav class="breadcrumbs">
|
||||
<a href="/">Home</a>
|
||||
<span class="sep">›</span>
|
||||
<span>{data.icon} {data.label}</span>
|
||||
</nav>
|
||||
|
||||
<h1 class="page-title">{data.icon} {data.label} Converters</h1>
|
||||
<p class="page-subtitle">
|
||||
{data.calculators.length} converter{data.calculators.length !== 1 ? 's' : ''} available in this category.
|
||||
Select any conversion below to get started.
|
||||
</p>
|
||||
|
||||
<div class="calc-list">
|
||||
{#each data.calculators as calc}
|
||||
<a href="/{calc.slug}" class="calc-list-item">
|
||||
{calc.name}
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
Reference in New Issue
Block a user