Add navigation to World Travel page and create server load function for country regions
This commit is contained in:
16
src/routes/worldtravel/[countrycode]/+page.server.ts
Normal file
16
src/routes/worldtravel/[countrycode]/+page.server.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// server laod function
|
||||
import { db } from '$lib/db/db.server.js';
|
||||
import { worldTravelCountryRegions } from '$lib/db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function load({ params }) {
|
||||
const { countrycode } = params;
|
||||
let data = await db
|
||||
.select()
|
||||
.from(worldTravelCountryRegions)
|
||||
.where(eq(worldTravelCountryRegions.country_code, countrycode))
|
||||
console.log(data)
|
||||
return {
|
||||
regions : data,
|
||||
};
|
||||
}
|
||||
7
src/routes/worldtravel/[countrycode]/+page.svelte
Normal file
7
src/routes/worldtravel/[countrycode]/+page.svelte
Normal file
@@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
{#each data.regions as region}
|
||||
<p>{region.name}</p>
|
||||
{/each}
|
||||
Reference in New Issue
Block a user