Add navigation to World Travel page and create server load function for country regions
This commit is contained in:
@@ -20,9 +20,12 @@
|
||||
async function toToLogin() {
|
||||
goto("/login");
|
||||
}
|
||||
async function toToSignup() {
|
||||
async function goToSignup() {
|
||||
goto("/signup");
|
||||
}
|
||||
async function goToWorldTravel() {
|
||||
goto("/worldtravel");
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
|
||||
@@ -67,6 +70,10 @@
|
||||
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
|
||||
>My Log</button
|
||||
>
|
||||
<button
|
||||
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
||||
on:click={goToWorldTravel}>World Tavel Log</button
|
||||
>
|
||||
{/if}
|
||||
<button class="btn btn-primary my-2 md:my-0" on:click={goToFeatured}
|
||||
>Featured</button
|
||||
@@ -82,7 +89,7 @@
|
||||
<div class="navbar-end flex justify-around md:justify-end mr-4">
|
||||
{#if !user}
|
||||
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
|
||||
<button class="btn btn-primary ml-4" on:click={toToSignup}>Signup</button>
|
||||
<button class="btn btn-primary ml-4" on:click={goToSignup}>Signup</button>
|
||||
{/if}
|
||||
|
||||
{#if user}
|
||||
|
||||
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