1
- # Building a SvelteKit app with sv and Deno
1
+ ---
2
+ title : " Building a SvelteKit app with sv and Deno"
3
+ url : /examples/sveltekit_tutorial/
4
+ ---
2
5
3
6
SvelteKit has been a stable popular vote since its launch and with Svelte
4
7
version 5 releasing recently, as of time of writing, there isn't a better time
@@ -124,16 +127,16 @@ All we are doing here is converting our map to an array so we can see them
124
127
rendered on the ` +page.svelte ` . Within this page you can remove anything you'd
125
128
like or just add the following.
126
129
127
- ``` svelte
130
+ ``` html
128
131
<script lang =" ts" >
129
- /// src/routes/+page.svelte
130
- let { data } = $props();
132
+ // / src/routes/+page.svelte
133
+ let { data } = $props ();
131
134
</script >
132
135
133
136
<section class =" mb-4 grid max-h-96 grid-cols-2 gap-4 overflow-y-auto" >
134
- {#each data.dinos as item}
135
- <a class="rounded border p-4" href="/{item.name}">{item.name}</a>
136
- {/each}
137
+ {#each data.dinos as item}
138
+ <a class =" rounded border p-4" href =" /{item.name}" >{item.name}</a >
139
+ {/each}
137
140
</section >
138
141
```
139
142
@@ -186,9 +189,9 @@ src/routes/+error.svelte
186
189
This is a very simple page, feel free to spruce up the styles here or add your
187
190
own flair!
188
191
189
- ``` svelte
192
+ ``` html
190
193
<script lang =" ts" >
191
- import { page } from ' $app/state' ;
194
+ import { page } from " $app/state" ;
192
195
</script >
193
196
194
197
<h1 >{page.status}: {page.error?.message}</h1 >
@@ -201,10 +204,10 @@ attached to the error.
201
204
Now with that pesky error distraction handled, pun intended, we can get back to
202
205
showing our individual dinosaur!
203
206
204
- ``` svelte
207
+ ``` html
205
208
<script lang =" ts" >
206
- /// src/routes/[name]/+page.svelte
207
- let { data } = $props();
209
+ // / src/routes/[name]/+page.svelte
210
+ let { data } = $props ();
208
211
</script >
209
212
210
213
<h1 >{data.name}</h1 >
@@ -231,28 +234,28 @@ Here are a few things we want to achieve:
231
234
2 . Show the awesome docs for Deno and SvelteKit
232
235
3 . Show a cute Dino on the page!
233
236
234
- ``` svelte
237
+ ``` html
235
238
<script lang =" ts" >
236
- import ' ../app.css' ;
237
- let { children } = $props();
239
+ import " ../app.css" ;
240
+ let { children } = $props ();
238
241
</script >
239
242
240
243
<header class =" flex flex-row place-content-between items-center p-4" >
241
- <h1 class="text-2xl"><a href="/">Deno Sveltekit</a></h1>
242
- <img id="deno" class="w-32" src="/vite-deno.svg" alt="Vite with Deno" />
244
+ <h1 class =" text-2xl" ><a href =" /" >Deno Sveltekit</a ></h1 >
245
+ <img id =" deno" class =" w-32" src =" /vite-deno.svg" alt =" Vite with Deno" />
243
246
</header >
244
247
245
248
<main class =" container mx-auto p-4" >
246
- {@render children()}
249
+ {@render children()}
247
250
</main >
248
251
249
252
<footer class =" my-4 flex flex-row justify-center gap-4" >
250
- <p class="font-bold">
251
- <a href="https://svelte.dev/docs/kit">Sveltekit docs</a>
252
- </p>
253
- <p class="font-bold">
254
- <a href="https://docs.deno.com/">Deno docs</a>
255
- </p>
253
+ <p class =" font-bold" >
254
+ <a href =" https://svelte.dev/docs/kit" >Sveltekit docs</a >
255
+ </p >
256
+ <p class =" font-bold" >
257
+ <a href =" https://docs.deno.com/" >Deno docs</a >
258
+ </p >
256
259
</footer >
257
260
```
258
261
@@ -343,7 +346,7 @@ export const load = async ({ url }) => {
343
346
Wuuf, that was a lot of work, and with it out of the way lets get some
344
347
pagination and search inputs added to the UI!
345
348
346
- ``` svelte
349
+ ``` html
347
350
<script lang =" ts" >
348
351
import { goto , invalidate , replaceState } from ' $app/navigation' ;
349
352
import { page as sveltePage } from ' $app/state' ;
0 commit comments