Skip to content
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

Inconsistent reference to reserved file names #833

Open
sacrosanctic opened this issue Nov 12, 2024 · 0 comments
Open

Inconsistent reference to reserved file names #833

sacrosanctic opened this issue Nov 12, 2024 · 0 comments

Comments

@sacrosanctic
Copy link

Issue

In the docs, a feature or API often applies to more than 1 reserved file. But they're displayed inconsistently.

Example 1

`true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
related to the data request in this case. Use this property instead if the distinction is important to you.

+page/layout.server.js

It is unclear where the forward slash begins and ends on the split. Does layout start with a plus? does +page also have a .server? Can also be confused with paths.

Example 2

In turn, annotating the `load` function with `PageLoad`, `PageServerLoad`, `LayoutLoad` or `LayoutServerLoad` (for `+page.js`, `+page.server.js`, `+layout.js` and `+layout.server.js` respectively) ensures that `params` and the return value are correctly typed.

Here it is listed separately, but always shows .js even though you toggle it to TS

Example 3

```js
/// file: +page.js/+page.server.js/+server.js
export const prerender = true;
```
Alternatively, you can set `export const prerender = true` in your root `+layout.js` or `+layout.server.js` and prerender everything except pages that are explicitly marked as _not_ prerenderable:

image

It doesn't list all the options; the rest is listed in the description. It is also very tight, it lists it out separately but uses a forward slash with no spacing.

Suggested Fixes

Dedicated UI

I suggest the docs site create a UI similar to <select /> that can handle this kind of permutation.

Prior Art:

  • I can't find any :/

Formatted Text

[+page.server.js | +layout.server.ts]
This gives it a distinctive look so readers can quickly skip over it.

Plain Text

+page.server.js, +layout.server.js
This is just formatted like English.

Additional Details

Currently, there are many reserved name combinations for which we cannot simply say *.server.js or +layout.*; it just starts to become cryptic.

Here is a list of all current file names with special meaning:

  • +page.svelte
  • +page.js
  • +page.server.js
  • +layout.svelte
  • +layout.js
  • +layout.server.js
  • +server.js
  • +error.svelte
  • *.svelte.js

Plus 7 more .ts files

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

No branches or pull requests

1 participant