Skip to content

Commit

Permalink
docs: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Jun 10, 2024
1 parent d226ee7 commit 3b83861
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
35 changes: 19 additions & 16 deletions docs/pages/file-structure/+Page.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Link } from '@brillout/docpress'
import { UiFrameworkExtension } from '../../components'

For advanced apps we recommend a domain-driven file structure using multiple `pages/` directories,
while for basic apps we recommend using a single `pages/` directory.
For advanced apps we recommend a domain-driven file structure using multiple `pages/` directories.

## Basic Apps
For basic apps we recommend using a single `pages/` directory.

## Basic

```yaml
# Landing page
Expand Down Expand Up @@ -63,7 +64,7 @@ while for basic apps we recommend using a single `pages/` directory.
export default '/product/@id'
```

Resulting route table:
Route table:

```
FILEYSTEM ROUTE
Expand All @@ -77,32 +78,36 @@ FILEYSTEM ROUTE
/products/pages/product/+Page.js /product/@id
```

> The directory `(marketing)` is ignored because it's wrapped by parentheses.
> The directory `(marketing)/` is ignored because it's wrapped by parentheses.
Such domain-driven file structure is also convenient for setting different default configurations.
Such domain-driven file structure is also convenient for having different configs:

```yaml
# Defaults
# Configs for marketing pages
/(marketing)/pages/+Layout.js
/(marketing)/pages/+title.js
/(marketing)/pages/+ssr.js
/(marketing)/pages/+prerender.js
# Pages

# Marketing pages
/(marketing)/pages/index/+Page.js
/(marketing)/pages/about/+Page.js
/(marketing)/pages/jobs/+Page.js

# Defaults
# Configs for admin pages
/admin-panel/pages/+Layout.js
/admin-panel/pages/+title.js
/admin-panel/pages/+config.js
# Pages

# Admin pages
/admin-panel/pages/index/+Page.js
/admin-panel/pages/edit-product/+Page.js
/admin-panel/pages/database/+Page.js
```

Note how <Link href="/config#inheritance">config inheritance</Link> applies:
- The `/(marketing)/pages/+*.js` files apply as default to all pages living at `/(marketing)/pages/**`.
- The `/admin-panel/pages/+*.js` files apply as default to all pages living at `/admin-panel/pages/**`.
- The `/(marketing)/pages/+*.js` configs apply to all pages living at `/(marketing)/pages/**`.
- The `/admin-panel/pages/+*.js` configs apply to all pages living at `/admin-panel/pages/**`.


Example:
Expand All @@ -118,12 +123,10 @@ You can embed `pages/` in `src/`:
/src/pages/about/+Page.js # => URL /about
```

See <Link href="/filesystem-routing" /> for more information.


## Without `vike-{react,vue,solid}`
## `renderer/`

In case you don't use a <UiFrameworkExtension />, we recommend placing your UI framework integration code in a `renderer/` directory.
If you don't use a <UiFrameworkExtension /> then we recommend placing your UI framework integration in a `renderer/` directory.

```yaml
# Same as above
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/filesystem-routing/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Vike crawls all files inside [Vite's `root` directory](https://vitejs.dev/config

In other words: all your <Link href="/config#files">`+` files</Link> need to live inside `root`.

> You can use soft symlinks (`$ ln -s`) to link outside directories into `root` and thus make them crawlable.
> You can use a soft symlink (`$ ln -s`) to make a directory outside of `root` crawlable.
If you use Git then Vike doesn't crawl and skips all directories defined by your `.gitignore` files.
If you use Git then Vike skips `.gitignore` files.


## See also
Expand Down
22 changes: 7 additions & 15 deletions docs/pages/routing/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ Vike supports *Filesystem Routing*: the URL of a page is determined by where the
```bash
FILESYSTEM URL
==================== ======
pages/about/+Page.js /about
pages/faq/+Page.js /faq
```
Note that `index/` and `src/` are mapped to the empty string:
```bash
FILESYSTEM URL
======================== ======
pages/index/+Page.js /
src/pages/index/+Page.js /
src/pages/about/+Page.js /about
pages/about/+Page.js /about
pages/jobs/+Page.js /jobs
```

> The directories `pages/`, `index/` and `src/` are ignored.
You can define parameterized routes:

```bash
Expand All @@ -31,20 +26,17 @@ pages/movie/@id/+Page.js /movie/1, /movie/2, ...

> The parameter `id` is available at <Link href="/pageContext">`pageContext.routeParams.id`</Link>.
You can setup a domain-driven file structure:
You can set up a domain-driven file structure:

```
FILESYSTEM URL
================================ ============
(marketing)/pages/index/+Page.js /
(marketing)/pages/about/+Page.js /about
user/pages/list/+Page.js /user/list
user/pages/create/+Page.js /user/create
todo/pages/list/+Page.js /todo/list
todo/pages/create/+Page.js /todo/create
admin-panel/pages/index/+Page.js /admin-panel
```

> The directory `(marketing)` is ignored because it's wrapped by parentheses.
> The directory `(marketing)/` is ignored because it's wrapped by parentheses.
More information at:
- <Link href='/file-structure#domain-driven' />
Expand Down

0 comments on commit 3b83861

Please sign in to comment.