Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
- name: Build docs
working-directory: ./docs
env:
NODE_ENV: production
PUBLIC_PATH: /showcase/
TEMPLATES_DIR: temp/templates
run: |
npm run check
npm run build
Expand Down
5 changes: 5 additions & 0 deletions docs/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# should be value public path
PUBLIC_PATH=/showcase/

# directory for SSG page templates
TEMPLATES_DIR=temp/templates
3 changes: 2 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
.generated/
dist/
dist/
temp/
2 changes: 2 additions & 0 deletions docs/docs/build/vite.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const meta = {

# Build with Vite

For Rspack you can see working example: [Vite example on GitHub](https://github.com/krutoo/showcase/tree/main/examples/vite)

With Vite you need to configure it for example like this:

```js
Expand Down
58 changes: 57 additions & 1 deletion docs/docs/showcase/customization.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,60 @@ Coming soon...

## Routing

Coming soon...
By default, showcase uses next routing rules:

- showcase page of story `/hello/world` looks for `?path=/hello/world`
- sandbox page of story `/hello/world` looks for `sandbox.html?path=/hello/world`

You can configure routing of your stories by **router** and **routing** options.

#### Option `router`

By this option you can configure how to deal with `window.location` if you want.
Default router is `BrowserRouter` that connects to `window.location`.

`BrowserRouter` can be exported and configured:

```jsx
import { ShowcaseApp, BrowserRouter } from '@krutoo/showcase/showcase-runtime';

<ShowcaseApp router={new BrowserRouter()}>
```

#### Option `routing`

This option controls how to:

- define story by location
- define location by story
- define story sandbox URL

By default `ShowcaseApp` uses `QueryRouting` that looks for `?path` parameter in location.

If you want to make pathname-based routing you can use `PathnameRouting`:

```jsx
import { ShowcaseApp, PathnameRouting } from '@krutoo/showcase/showcase-runtime';

<ShowcaseApp routing={new PathnameRouting()}>
```

It also of course possible to provide your own implementation.

Notice that for pathname-based routing you also need to either:

- make HTML files for each story during compile time
- configure your server to redirect all missed pathnames to your SPA

#### Tip: public path

If you want to publish your showcase to non root path you can provide `publicPath` option to `PathnameRouting`:

```jsx
import { ShowcaseApp, PathnameRouting } from '@krutoo/showcase/showcase-runtime';

<ShowcaseApp routing={new PathnameRouting({ publicPath: '/hello/' })}>
```

For example, `docs` repo published to GitHub Pages will have url `github.com/<username>/docs`
where `username` is _base path_.
Loading