Skip to content

Commit

Permalink
docs: improve advanced routing documentation (#5276)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen authored Oct 5, 2023
1 parent c089800 commit d845445
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contributors:
- cunzaizhuyi
- the-r3aper7
- mhevery
- jakovljevic-mladen
---

# Advanced Routing
Expand Down Expand Up @@ -125,13 +126,15 @@ At times related routes need to have drastically different layouts from their si

Qwik City defines the convention that layouts are within `src/routes` and the filename starts with `layout`. That's why the default layout is named `layout.tsx`. A named layout also starts with `layout` followed by a dash `-` and a unique name, such as `layout-narrow.tsx`.

To reference a named layout, the route's `index.tsx` file must be suffixed with `@<name>`. For example, `[email protected]` would use the `layout-narrow.tsx` layout.

```bash
src/
└── routes/
├── contact/
│ └── [email protected] # https://example.com/contact (Layout: layout-narrow.tsx)
├── layout.tsx # Default layout
├── layout-narrow.tsx # Default named layout
├── layout-narrow.tsx # Named layout
└── index.tsx # https://example.com/ (Layout: layout.tsx)
```

Expand Down Expand Up @@ -243,3 +246,10 @@ You can have multiple `plugin.ts` files, each with a different name. For example

Requests handlers like `onRequest`, `onGet`, `onPost`, etc. are called before `server$` functions are executed.

### The order of execution of `plugin.ts` files

If `plugin.ts` file exists and if it has exported request handlers, then they are executed first.

Then exported request handlers from `plugin@<name>.ts` files are executed in alphabetical order of the file names. For example, `onGet` from `[email protected]` is executed before `onGet` from `[email protected]` because `auth` is alphabetically before `security`.

Finally, if a `server$` function exists, it's executed last.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ keywords: 'authentication, auth, oauth'
contributors:
- the-r3aper7
- ulic75
- jakovljevic-mladen
---

# Auth.js
Expand Down

0 comments on commit d845445

Please sign in to comment.