diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 19052f87..b6342745 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -13,6 +13,10 @@ on:
required: false
type: string
default: 'https://github.com/${{ github.repository }}/raw/${{ github.ref_name }}'
+ home_redirect:
+ required: true
+ type: string
+ default: '/getting-started/introduction'
jobs:
build-job:
@@ -32,16 +36,16 @@ jobs:
-e MDX \
-e NEXT_PUBLIC_LIBNAME \
-e OUTPUT=export \
+ -e HOME_REDIRECT \
-e INLINE_IMAGES_ORIGIN \
ghcr.io/pmndrs/docs:app-router npm run build
env:
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}
MDX: ${{ inputs.mdx }}
NEXT_PUBLIC_LIBNAME: ${{ inputs.libname }}
+ HOME_REDIRECT: ${{ inputs.home_redirect }}
INLINE_IMAGES_ORIGIN: ${{ inputs.inline_images_origin }}
- - run: ls -al ${{ inputs.mdx }}
-
- uses: actions/upload-pages-artifact@v3
with:
path: ${{ inputs.mdx }}/out${{ steps.configurepages.outputs.base_path }}
diff --git a/readme.md b/readme.md
index b0d08771..bdbbd00e 100644
--- a/readme.md
+++ b/readme.md
@@ -1,36 +1,50 @@
+| var | description | default |
+| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
+| `MDX`\* | Path to `*.mdx` folder
NB: can be relative or absolute | none |
+| `NEXT_PUBLIC_LIBNAME`\* | Library name | none |
+| `BASE_PATH` | base path for the final URL | none |
+| `DIST_DIR` | Path to the output folder | none |
+| `OUTPUT` | Set to `export` for static `out`put | none |
+| `HOME_REDIRECT` | Where the home should redirect | none |
+| `INLINE_IMAGES_ORIGIN` | [Origin](https://developer.mozilla.org/en-US/docs/Web/API/URL/origin) for inlining relative images
Eg: in a `/advanced/introduction.mdx` file, `` becomes ``
NB: if none, don't use relative images | none |
+
+# dev
+
```sh
$ MDX=~/code/pmndrs/react-three-fiber/docs \
NEXT_PUBLIC_LIBNAME="React Three Fiber" \
BASE_PATH= \
DIST_DIR= \
OUTPUT=export \
+ HOME_REDIRECT=/getting-started/introduction \
+ INLINE_IMAGES_ORIGIN= \
npm run dev
```
-http://localhost:3000/getting-started/introduction
+Then go to: http://localhost:3000
+
+> [!TIP]
+> If `HOME_REDIRECT=` empty, `/` will not redirect, and instead displays an index of libraries.
+
+# build
```sh
$ rm -rf out; \
+ \
MDX=~/code/pmndrs/react-three-fiber/docs \
NEXT_PUBLIC_LIBNAME="React Three Fiber" \
BASE_PATH= \
DIST_DIR= \
OUTPUT=export \
+ HOME_REDIRECT=/getting-started/introduction \
+ INLINE_IMAGES_ORIGIN= \
npm run build && \
+ \
npx serve out
```
http://localhost:3000/getting-started/introduction
-| var | description | default |
-| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
-| `MDX`\* | Path to `*.mdx` folder
NB: can be relative or absolute | none |
-| `NEXT_PUBLIC_LIBNAME`\* | Library name | none |
-| `BASE_PATH` | base path for the final URL | none |
-| `DIST_DIR` | Path to the output folder | none |
-| `OUTPUT` | Set to `export` for static `out`put | none |
-| `INLINE_IMAGES_ORIGIN` | [Origin](https://developer.mozilla.org/en-US/docs/Web/API/URL/origin) for inlining relative images
Eg: in a `/advanced/introduction.mdx` file, `` becomes ``
NB: if none, don't use relative images | none |
-
\* Required
# Docker
@@ -45,8 +59,11 @@ $ export BASE_PATH=/react-three-fiber; \
export MDX=./docs; \
export NEXT_PUBLIC_LIBNAME="React Three Fiber"; \
export OUTPUT=export; \
+ export HOME_REDIRECT=/getting-started/introduction; \
+ export INLINE_IMAGES_ORIGIN=; \
\
rm -rf "$MDX/out"; \
+ \
docker run --rm --init -it \
-v "$MDX":/app/docs \
-e BASE_PATH \
@@ -54,8 +71,11 @@ $ export BASE_PATH=/react-three-fiber; \
-e MDX \
-e NEXT_PUBLIC_LIBNAME \
-e OUTPUT \
+ -e HOME_REDIRECT \
+ -e INLINE_IMAGES_ORIGIN \
pmndrs-docs npm run build && \
+ \
npx -y serve "$MDX/out"
```
-Then go to http://localhost:3000/react-three-fiber/getting-started/introduction
+Then go to: http://localhost:3000/react-three-fiber
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 8d6cb1b6..a16e30cf 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -109,7 +109,8 @@ const libs: Record = {
}
export default function Page() {
- if (process.env.OUTPUT === 'export') redirect('/getting-started/introduction')
+ const HOME_REDIRECT = process.env.HOME_REDIRECT
+ if (HOME_REDIRECT) redirect(HOME_REDIRECT)
return (
<>