Skip to content

Commit 7718559

Browse files
committed
FIX: Wording and video links.
1 parent 1740506 commit 7718559

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

examples/tutorials/sveltekit.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
SvelteKit has been a stable popular vote since its launch and with Svelte version 5 releasing recently, as of time of writing, there isn't a better time to show off running it with Deno!
44

5-
Through this tutorial we will walk through setting up a SvelteKit project, made much easier with the sv cli release and look at loading patters.
5+
Through this tutorial we will walk through setting up a SvelteKit project, made easier with the sv cli release and look at loading patters.
66

77
You can see the finished app at [GitHub](https://github.com/s-petey/deno-sveltekit)
88

9-
<!-- TODO: Add gif / video of the app sv_create -->
10-
119
## Getting started
1210

1311
We can scaffold an application easily with `npx sv create`. This is [SvelteKit's CLI](https://github.com/sveltejs/cli) which has a lot of utility.
1412

15-
<!-- Insert video DRAG AND DROP online -->
13+
https://github.com/user-attachments/assets/8357d46b-b535-44e3-9191-1496e0632bd1
1614

17-
If you have followed the video above great! if not, here are the selections:
15+
If you have followed the video above great! If not, here are the selections:
1816

1917
- Template
2018
- SvelteKit minimal
@@ -30,21 +28,21 @@ If you have followed the video above great! if not, here are the selections:
3028
- Package manager
3129
- Deno
3230

33-
For the remainder of this you should have `deno task dev` running in the background so you can see your changes and the application running locally!
31+
For the remainder of this, you should have `deno task dev` running in the background so you can see your changes and the application running locally.
3432

3533
### Walkthrough
3634

3735
There are a few different folders to be mindful of.
3836

39-
`src` this is the root of your application code and where most of your time and effort will go into.
37+
`src` this is the root of your application code and where most of your time and effort will go.
4038

41-
`src/lib` this is a SvelteKit aliased directory for fast import and where a lot of your helpers or library code will live.
39+
`src/lib` this is a SvelteKit aliased directory for fast import and where many of your helpers or library code will live.
4240

43-
`src/routes` this is the rendered pages for your application with SvelteKit there is folder routing.
41+
`src/routes` this is the rendered pages for your application with SvelteKit, there is folder routing.
4442

4543
#### Good info
4644

47-
There are a few conventions which we will use in our SvelteKit application. There are more but I am only covering the ones used.
45+
There are a few conventions which we will use in our SvelteKit application. (Although there are more available, I am only covering the ones used).
4846

4947
- Files or folders with `server` in the name are meant to **only** be run on the server and may cause errors if you try to run them in the client.
5048
- Within `src/routes` files have a naming conventions:
@@ -91,7 +89,7 @@ We now need to create a `+page.server.ts` file which will be at the root of our
9189
src/routes/+page.server.ts
9290
```
9391

94-
With this file created now we need to initialize the function to load our dinos!
92+
With this file created, we need to initialize the function to load our dinos!
9593

9694
```ts
9795
/// src/routes/+page.server.ts
@@ -102,7 +100,7 @@ export const load = async ({ url }) => {
102100
});
103101
```
104102

105-
All we are doing here is converting our map to an array so we can see them rendered on the `+page.svelte`. Within this page you can remove everything if you'd like or just add the following.
103+
All we are doing here is converting our map to an array so we can see them rendered on the `+page.svelte`. Within this page you can remove anything you'd like or just add the following.
106104

107105
```svelte
108106
<script lang="ts">
@@ -121,14 +119,14 @@ Notice while you are working with `data` we have type safety to know that `data.
121119

122120
### Adding an individual Dino page
123121

124-
Now that we are rendering each dino and have links on each of them setup we can add a route to handle rendering this data.
122+
Now that we are rendering each dino and have links on each of them setup, we can add a route to handle rendering this data.
125123

126124
```
127125
src/routes/[name]/+page.server.ts
128126
src/routes/[name]/+page.svelte
129127
```
130128

131-
There is something neat and unique about this route. I am sure you noticed the `[name]` inserted as a folder name. This allows us to have a named route parameter. We could have used anything as the `name` here, however we want to be able to route to `localhost:5173/Ingenia` and see our dinosaur and since that is the name I've used the parameter `name`.
129+
There is something neat and unique about this route. I am sure you noticed the `[name]` inserted as a folder name. This allows us to have a named route parameter. We could have used anything as the `name`, however we want to be able to route to `localhost:5173/Ingenia` and see our dinosaur and since that is the name I've used the parameter `name`.
132130

133131
With that explained now we can access this without our server loader to get our dino and send it to the page!
134132

@@ -164,7 +162,7 @@ This is a very simple page, feel free to spruce up the styles here or add your o
164162
<h1>{page.status}: {page.error?.message}</h1>
165163
```
166164

167-
We simply want to show that something went wrong and with the `page` exposed by SvelteKit we can show the status code thrown and if there was a message attached to the error.
165+
We simply want to show that something went wrong and with the `page` exposed by SvelteKit, we can show the status code thrown and if there was a message attached to the error.
168166

169167
Now with that pesky error distraction handled, pun intended, we can get back to showing our individual dinosaur!
170168

@@ -179,15 +177,15 @@ Now with that pesky error distraction handled, pun intended, we can get back to
179177
<p>{data.description}</p>
180178
```
181179

182-
Sorry for the simplicity of styling here, but you can see here we still get the type safety knowing a `name` and `description` will exist on our data and we can render it!
180+
Starting to work on this page you can see we still get the type safety knowing a `name` and `description` will exist on our data and we can render it!
183181

184-
However there is another problem if you navigate to this page, either by clicking on one of the links on the main page or by manually adding the dinosaur name to the URL we have no way of getting back!
182+
However, there is another problem if you navigate to this page, either by clicking on one of the links on the main page or by manually adding the dinosaur name to the URL we have no way of getting back!
185183

186184
### Layouts
187185

188-
We want to have a standard layout so that our pages can share different information or links. This can be achieved through `+layout.svelte` pages lets go ahead and update the one up at the root of the `routes` directory.
186+
We want to have a standard layout so that our pages can share different information or links. This can be achieved through `+layout.svelte` pages. Lets go ahead and update the one up at the root of the `routes` directory.
189187

190-
There are a few things we want to achieve here:
188+
Here are a few things we want to achieve:
191189

192190
1. Allow users to navigate to the home page
193191
2. Show the awesome docs for Deno and SvelteKit
@@ -218,17 +216,17 @@ There are a few things we want to achieve here:
218216
</footer>
219217
```
220218

221-
We are seeing `{@render children()}` for the first time here. All it does is works as an "outlet" if you are coming from the React world to just render whatever other child page may need to be output there.
219+
As you see, we are seeing `{@render children()}` for the first time. This just works as an "outlet" if you are coming from the React world to render whatever other child page may need to be output.
222220

223-
Now if you go back to your application you can see our heading `h1` has a link to go back to the home page!
221+
Going back to your application you can see our heading `h1` has a link to go back to the home page.
224222

225223
### Advanced routing, search parameters, and styling
226224

227-
We don't want to render all of the dinos at a single time as that is too much to scroll through. We want our users to be able to search and click through pages of dinosaurs. This will also showcase another awesome Svelte 5 feature, snippets!
225+
We don't want to render all of the dinos at a single time; as that is too much to scroll through. We want our users to be able to search and click through pages of dinosaurs, which will also showcase another awesome Svelte 5 feature, snippets!
228226

229227
Lets open our main page and its server page to make a few changes.
230228

231-
Previously we were just returning an array version of our dinos lets allow users to search them and add some pagination logic.
229+
Previously we were returning an array version of our dinos, lets allow users to search them and add some pagination logic.
232230

233231
```ts
234232
import { dinos } from '$lib/server/dino.js';
@@ -295,7 +293,7 @@ export const load = async ({ url }) => {
295293
};
296294
```
297295

298-
Wuuf that was a lot of work and with it out of the way lets get some pagination and search inputs added to the UI!
296+
Wuuf, that was a lot of work, and with it out of the way lets get some pagination and search inputs added to the UI!
299297

300298
```svelte
301299
<script lang="ts">
@@ -406,10 +404,12 @@ Wuuf that was a lot of work and with it out of the way lets get some pagination
406404

407405
Notice for the input we use `defaultValue={data.q ?? ''}` so that when it is rendered in the UI we don't get `undefined` or `null` showing.
408406

409-
With snippets you can create re-useable parts of Svelte code for easier rendering. `{#snippet pageButton(...)}` allows us to define the section to be rendered. Then we can use it and pass the required type safe parameters using `{@render pageButton(...)}`. You can see this for all of the pagination buttons.
407+
With snippets you can create re-useable parts of Svelte code for easier rendering. `{#snippet pageButton(...)}` allows us to define the section to be rendered. We can then use it and pass the required type safe parameters using `{@render pageButton(...)}`. You can see this for all of the pagination buttons.
410408

411-
Another neat Svelte trick is that whenever we have `<style>` defined on the page that is scoped only to the file it is used in. So we are able to add these classes knowing that it will not effect any of our other files if they also used that styling.
409+
Another neat Svelte trick is whenever `<style>` is defined on the page, it is scoped only to the file it is used in. So we are able to add these classes knowing that it will not affect any of our other files if they also used that styling.
412410

413411
I have updated some of the styling to make it more pleasant to look at, but I know you have great taste and are free to make it look however you'd like!
414412

415-
<!-- TODO: Add video of application running app_showcase -->
413+
# App Showcase
414+
415+
https://github.com/user-attachments/assets/c5926d48-1ea3-420f-9d3d-d74a5a49486a

0 commit comments

Comments
 (0)