Skip to content

Loading #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c4f317f
shuffle sections around
Rich-Harris Dec 5, 2022
8307b68
update error page
Rich-Harris Dec 5, 2022
7f3ea19
update params section
Rich-Harris Dec 5, 2022
33d481f
rename
Rich-Harris Dec 5, 2022
1416826
update some content
Rich-Harris Dec 5, 2022
7ff8dc5
HN example
Rich-Harris Dec 5, 2022
166a085
update API route docs
Rich-Harris Dec 5, 2022
f49fabe
merge
Rich-Harris Dec 5, 2022
16391ac
fix script
Rich-Harris Dec 5, 2022
647a7c8
tweaks
Rich-Harris Dec 5, 2022
cc5c5e8
typo
Rich-Harris Dec 5, 2022
5755f80
fixes
Rich-Harris Dec 5, 2022
49621a3
fix
Rich-Harris Dec 5, 2022
811338f
tweaks
Rich-Harris Dec 5, 2022
9e8ab7a
use __delete
Rich-Harris Dec 5, 2022
eab684f
add some css
Rich-Harris Dec 5, 2022
6512a90
allow files to be marked for deletion
Rich-Harris Dec 5, 2022
b138c7c
[chore] bump deps
dummdidumm Dec 6, 2022
d2c6d4d
[chore] robustify create-middleware
dummdidumm Dec 6, 2022
0b51466
[chore] handle offline case in +error.svelte
dummdidumm Dec 6, 2022
ba7fec9
[fix] style "/// file: .." pragmas in code blocks
dummdidumm Dec 6, 2022
2fc0409
[feat] __delete inside file means delete that file
dummdidumm Dec 6, 2022
ad3b61e
Merge branch 'main' into loading
dummdidumm Dec 6, 2022
16b9cd6
next
dummdidumm Dec 6, 2022
8fccb52
fix lockfile
dummdidumm Dec 6, 2022
df50dd5
tweaks
dummdidumm Dec 6, 2022
a91a296
[feat] __hidden file to mark folders as hidden
dummdidumm Dec 6, 2022
fa58f9b
Merge branch 'main' into loading
dummdidumm Dec 6, 2022
0f2536b
use hidden API instead
dummdidumm Dec 6, 2022
d4cffc1
Update content/tutorial/02-sveltekit/02-routing/07-api-routes/README.md
Rich-Harris Dec 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ The next steps depend on whether you want to run this locally in filesystem mode

1. if an `.env` file exists, modify it so there's `PUBLIC_USE_FILESYSTEM=` in it
2. Run the app locally with `pnpm dev` or `pnpm build && pnpm preview`.

## Creating new tutorials

Tutorials live inside `content`. Each tutorial consists of a `README.md`, which is the text to the left, and `app-a` and `app-b` folders, which represent the initial and solved state. Files that stay the same can be omitted from `app-b`. Files are marked as deleted in `app-b` if they start with `__delete`. Folders that are marked as deleted in `app-b` if they contain a file named `__delete`. Folders that contain a file named `__hidden` are not visible in the file tree.
31 changes: 18 additions & 13 deletions content/tutorial/02-sveltekit/02-routing/01-pages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ In this app we currently have one route — `src/routes/+page.svelte`, which map

Let's add a second route, `src/routes/about/+page.svelte`, which maps to `/about`:

```diff
src/routes/
+├ about/
+│ └ +page.svelte
└ +page.svelte
```

Clicking the `about` link on the home page will now take you to the about page (which is empty right now).

Let's add some content (including a link back to the homepage) to `src/routes/about/+page.svelte` :

```svelte
+++<h1>About</h1>
/// file: src/routes/about/+page.svelte
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>

<h1>About</h1>

<p>This is the about page.</p>
<p>Go to the <a href="/">home</a> page</p>+++

<style>
nav {
display: flex;
gap: 1em;
padding: 1em;
background-color: #eee;
}
</style>
```

We can now navigate between `/` and `/about`.

> Unlike traditional multi-page apps, navigating to `/about` and back updates the contents of the current page, like a single-page app. This gives us the best of both worlds — fast server-rendered startup, then instant navigation.
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>

<h1>Home</h1>

<p>This is the home page.</p>
<p>Go to the <a href="/about">about</a> page.</p>

<style>
nav {
display: flex;
gap: 1em;
padding: 1em;
background-color: #eee;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>

<h1>Home</h1>

<p>This is the home page.</p>

<style>
nav {
display: flex;
gap: 1em;
padding: 1em;
background-color: #eee;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>

<h1>About</h1>

<p>This is the about page.</p>
<p>Go to the <a href="/">home</a> page</p>

<style>
nav {
display: flex;
gap: 1em;
padding: 1em;
background-color: #eee;
}
</style>
7 changes: 4 additions & 3 deletions content/tutorial/02-sveltekit/02-routing/02-layouts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ src/routes/
...and move the duplicated content from the `+page.svelte` files into the new `+layout.svelte` file. The `<slot />` element is where the page content will be rendered:

```svelte
+++<nav>
/// file: src/routes/about/+page.svelte
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
Expand All @@ -31,7 +32,7 @@ src/routes/
padding: 1em;
background-color: #eee;
}
</style>+++
</style>
```

> Layouts can also be nested
A `+layout.svelte` file applies to every child route, including the sibling `+page.svelte` (if it exists). You can nest layouts to arbitrary depth.
46 changes: 0 additions & 46 deletions content/tutorial/02-sveltekit/02-routing/03-loading-data/README.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions content/tutorial/02-sveltekit/02-routing/03-params/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Route parameters
---

To create routes with dynamic parameters, use square brackets around a valid variable name. For example, a file like `src/routes/blog/[slug]/+page.svelte` will create a route that matches `/blog/one`, `/blog/two`, `/blog/three` and so on.

Let's create that file:

```svelte
/// file: src/routes/blog/[slug]/+page.svelte
<h1>Blog post</h1>
```

We can now navigate from the `/blog` page to individual blog posts. In the next section, we'll see how to load their content.

> Multiple route parameters can appear _within_ one URL segment, as long as they are separated by at least one static character: `foo/[bar]x[baz]` is a valid route where `[bar]` and `[bar]` are dynamic parameters.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<h1>TODO</h1>

<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/blog">Blog</a>
</nav>

<slot />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Blog</h1>

<ul>
<li><a href="/blog/one">one</a></li>
<li><a href="/blog/two">two</a></li>
<li><a href="/blog/three">three</a></li>
</ul>
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<h1>TODO</h1>

<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/blog">Blog</a>
</nav>

<slot />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Blog</h1>

<ul>
<li><a href="/blog/one">one</a></li>
<li><a href="/blog/two">two</a></li>
<li><a href="/blog/three">three</a></li>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Blog post</h1>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading