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

Loading #115

merged 30 commits into from
Dec 6, 2022

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Dec 5, 2022

This updates the loading section per https://github.com/sveltejs/learn.svelte.dev/pull/105/files#r1038350603.

Couple of things to note:

  • it uses the /// file: some-file-name.js convention from the Kit docs, but there's no CSS in place for that just yet, so it looks a bit funky
  • the event.fetch(...) call in the Hacker News example doesn't work, because the response is truncated. I can only assume this is a problem with WebContainers somehow, but I haven't investigated yet
  • We need a way to rename/delete files. Also, up till now app-b was assumed to be additive, but in reality there are times when app-a contains files that shouldn't exist when the exercise is solved

I think it's probably worth merging the content into tutorial-routing and worrying about the functionality later

@vercel
Copy link

vercel bot commented Dec 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
learn-svelte-dev ✅ Ready (Inspect) Visit Preview Dec 6, 2022 at 4:18PM (UTC)

@dummdidumm
Copy link
Member

Deleting files is already possible. It's not that pretty, but if you create a folder with the file __delete in it, it will mark the path above it as " will be removed". So if you want to delete a file you would do src/routes/+page.svelte/__delete . You can see it 'in action' in the advanced SvelteKit tutorial

@Rich-Harris
Copy link
Member Author

What do you think about requiring app-b to be complete, and expecting any files that are in app-a but not app-b to have been deleted? Do we think that would create more work or less work in the long run?

@dummdidumm
Copy link
Member

I think it would create more work, there are not that many tutorials that need deleting of files, most are additive. But I noticed that it's sometimes hard to keep track of what the finished app looks like, keeping content from app-a in your head, so it's probably a worthwhile change regardless - if we didn't implement most of this already 😅 so maybe in a cleanup PR afterwards

@Rich-Harris
Copy link
Member Author

Yeah, was just commenting that I do quite like the fact that changes to files in app-a don't need to be duplicated in app-b — it's easy for things to get out of sync.

What if instead of +page.svelte/__delete we just replaced the contents of +page.svelte with __DELETE__ (or whatever)? Feels slightly tidier

@dummdidumm
Copy link
Member

I'm fine either way

@Rich-Harris
Copy link
Member Author

Ah, I see — directory/__delete removes the entire directory. I think it's worth doing it both ways, just because renaming a file foo to foo/__delete in VSCode is a PITA since you have to rename it before you can create the directory

dummdidumm and others added 7 commits December 6, 2022 10:54
Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
@dummdidumm
Copy link
Member

dummdidumm commented Dec 6, 2022

I see that you added notes on $types - frankly, I would completely remove those references, and worry about that later. Right now, they don't work at all in the context of the tutorial, and it will inevitably lead to "but where's the TypeScript version" questions - so from an expectation management perspective, it's better to leave it out.

<div>{@html data.post.content}</div>+++
```

There's one last detail we need to take care of — the user might visit an invalid pathname like `/blog/nope`, in which case we'd like to respond with a 404 page:
Copy link
Member

@dummdidumm dummdidumm Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this part of the tutorial? If we just gloss over this for now, almost noone would notice, and it's one less thing to worry about for now. Furthermore, this is pretty much all there is to explain about expected errors, so the later section where this is explained would feel rather duplicative.

(would also give room to add that "notice how we can colocate stuff" info box I wrote previously, which I thought is a nice argument in favor of our +convention)

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me - great work! This feels a lot more fleshed out now. Left a few small comments, and one on the $types situation, which I think we should solve by leaving this out of the tutorial for now.

Another idea for solving the hacker news thing would be to create a similar convention to __delete: if there's a __hidden file inside a folder, that folder and all its contents don't appear in the file tree. That way, we can say that there's some external API at api/blog or sth like that. It has the added benefit of being able to reuse the same blog contents and being more reliable (also, the outgoing links don't work). I'll try that in a separate commit, which we can revert if you don't like it.

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@Rich-Harris Rich-Harris merged commit ca32193 into tutorial-routing Dec 6, 2022
@Rich-Harris Rich-Harris deleted the loading branch December 6, 2022 16:43
Rich-Harris added a commit that referenced this pull request Dec 12, 2022
* start of routing tutorial

* more chapters

* slots

* chapter skeletons

* mutating data section

* Apply suggestions from code review

Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>

* errors and redirects chapter

* invalidation chapter

* render options section

* add missing meta.json files

* advanced routing wip

* fix link

* matching, groups

* use new capabilities to adjust tutorials

* remove duplicate layout from page

* more sections

* tweaks

* remove log

* disable csrf for tutorial

* more content

* fix interval

* leverage adding files functionality for error tutorial

* simplify

* tweak tutorials so people have to create the files

* tweaks

* tweaks and fixes

* Update content/tutorial/02-sveltekit/03-mutating-data/04-progressive-enhancement/README.md

Co-authored-by: Geoff Rich <4992896+geoffrich@users.noreply.github.com>

* switch example, because alert will prevent the ping events, resulting in an endless alert loop because of constant iframe reloads

* labels for inputs

* tweaks and fixes

* fix

* environment variables tutorial

* fixes

* Update content/tutorial/02-sveltekit/01-concepts/03-server-and-client/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/01-concepts/03-server-and-client/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/01-concepts/04-server-side-rendering/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/01-concepts/04-server-side-rendering/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/01-concepts/05-prerendering/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/01-concepts/05-prerendering/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/01-concepts/05-prerendering/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/app-a/src/routes/+page.svelte

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/app-a/src/routes/about/+page.svelte

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/02-layouts/app-b/src/routes/+layout.svelte

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/03-loading-data/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/04-loading-layout-data/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/02-routing/07-params/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/03-mutating-data/02-form-validation/app-b/src/routes/+page.server.js

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* lowercase

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/06-rendering-options/02-ssr/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/02-sveltekit/06-rendering-options/03-csr/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/04-advanced-sveltekit/01-advanced-routing/01-optional-params/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/04-advanced-sveltekit/01-advanced-routing/02-rest-params/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/04-advanced-sveltekit/01-advanced-routing/03-param-matchers/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update content/tutorial/04-advanced-sveltekit/01-advanced-routing/04-layout-groups/README.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* move explanatory content from concepts into render options chapter

* remove backticks

* Update content/tutorial/02-sveltekit/02-routing/05-loading-server-data/README.md

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>

* Update content/tutorial/02-sveltekit/02-routing/03-loading-data/README.md

* Loading (#115)

* shuffle sections around

* update error page

* update params section

* rename

* update some content

* HN example

* update API route docs

* fix script

* tweaks

* typo

* fixes

* fix

* tweaks

* use __delete

* add some css

* allow files to be marked for deletion

* [chore] bump deps

* [chore] robustify create-middleware

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* [chore] handle offline case in +error.svelte

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* [fix] style "/// file: .." pragmas in code blocks

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* [feat] __delete inside file means delete that file

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* next

* fix lockfile

* tweaks

* [feat] __hidden file to mark folders as hidden

* use hidden API instead

* Update content/tutorial/02-sveltekit/02-routing/07-api-routes/README.md

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

* fix casing

* note configurability

* remove mention of vite

* fix solve button styles

* only add data-file attribute to files

* separate routing and loading into separate sections, etc

* remove $types, for now

* move stuff

* use a todo list example - better showcases PE, avoids complexity around user/session management

* swap exercise order

* flesh out form examples

* move invalidation to advanced section

* tweak page options docs

* move

* flesh out example to show use of page store etc

* small tweaks

* better redirects tutorial

* move $page.X usage into second chapter

* await parent

* tweaks

* better private env tutorials

* get rid of VITE_ prefix

* fix gitignore

* remove logging

* fix

* fixes

* invalid -> fail

* robustify

* rename section to the less-ambiguous "exercise" for my own sanity

* allow an exercise to inherit files from previous exercises to reduce duplication

* remove some now-unnecessary files

* delete file

* hide error customisation exercise for now - not ready to talk about hooks

* update errors and redirects section

* more detail

* tweaks

* add inspector

* formatting

* make "next" links more sensible

* fix chaining logic

* update optional params example

* rest params example

* different param matcher example

* tidy up

* move some content around

* add placeholder chapters on hooks and stores

* env var stuff

* oops, didnt mean to add these

* tweak

* style tweaks

* move filetree components to separate folder to ease future refactoring

* tweaks

* remove warning spiel

* update deps

* use a regex

* Revert "use a regex"

This reverts commit ac9f872.

* try this instead

* use +layout.server.js instead of tutorial.json

* make typescript a bit less complainy

* show current exercise in menu

* refactor filetree stuff a bit

* remove unused import

* simplify file creation, always select newly created file

* move icons

* oops

* derive depth at point of use

* simplify renaming

* simplify

* refactor filetree

* remove unused import

* make editing constraints visible - is more accessible etc

* use a store for filesystem state

* make constraints more granular

* DRY things out a bit

* more DRYing out

* insertion order

* various fixes

* a11y fix

* fix

* context menu styling

* fixes

* DRY out actions

* fix

* fix

* fix

* DRY out some more

* refactor

* split up env var exercises

* fix

* put <img> inside <button>

* remove some unnecessary files

* add route group example that includes a load function

* shuffle things around a bit

* make breakout example more visual

* oops

* bump kit

* add way to relax file tree constraints

* fix complete/reset state toggle

* pretty sure we actually want to check in the lockfile

* tweak

* remove TODO

* tweak example

* demonstrate returning non-serializable data from load function

* rename exercise to invalidation

* show a case where one load is invalidated and one isnt

* follow previous exercise, use generic data:blah key

* follow previous exercise

* add coming soon messages to get us off the hook for now

* remove old TODO

* work around hotlinking limitation

* remove __hidden mechanism, its way too confusing. comment out this exercise until we can investigate truncated bodies

* add some default styles etc

* more tidying up

* explain CSRF stuff

Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
Co-authored-by: Geoff Rich <4992896+geoffrich@users.noreply.github.com>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants