Skip to content

Commit

Permalink
OUTPUT
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed Aug 10, 2024
1 parent 9916610 commit 896587a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 54 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
-e DIST_DIR="$MDX/out$BASE_PATH" \
-e MDX \
-e NEXT_PUBLIC_LIBNAME \
-e OUTPUT=export \
ghcr.io/pmndrs/docs:app-router npm run build
env:
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}
Expand Down
101 changes: 51 additions & 50 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const basePath = process.env.BASE_PATH || ''
const distDir = process.env.DIST_DIR || undefined
const output = process.env.OUTPUT || undefined

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -9,57 +10,57 @@ const nextConfig = {
unoptimized: true,
},
basePath,
output: 'export',
distDir,
// async redirects() {
// return [
// {
// source: '/home',
// destination: '/',
// permanent: true,
// },
// {
// source: '/docs/:slug*',
// destination: '/:slug*',
// permanent: true,
// },
// {
// source: '/xr',
// destination: '/xr/getting-started/introduction',
// permanent: true,
// },
// {
// source: '/jotai',
// destination: 'https://jotai.pmnd.rs/docs/introduction',
// permanent: true,
// },
// {
// source: '/jotai/:slug*',
// destination: 'https://jotai.pmnd.rs/docs/:slug*',
// permanent: true,
// },
// {
// source: '/react-spring',
// destination: 'https://react-spring.io',
// permanent: true,
// },
// {
// source: '/react-spring/:slug*',
// destination: 'https://react-spring.io/#:slug*',
// permanent: true,
// },
// {
// source: '/drei',
// destination: 'https://github.com/pmndrs/drei#readme',
// permanent: true,
// },
// {
// source: '/drei/:slug*',
// destination: 'https://github.com/pmndrs/drei#:slug*',
// permanent: true,
// },
// ]
// },
output,
async redirects() {
return [
{
source: '/home',
destination: '/',
permanent: true,
},
{
source: '/docs/:slug*',
destination: '/:slug*',
permanent: true,
},
{
source: '/xr',
destination: '/xr/getting-started/introduction',
permanent: true,
},
{
source: '/jotai',
destination: 'https://jotai.pmnd.rs/docs/introduction',
permanent: true,
},
{
source: '/jotai/:slug*',
destination: 'https://jotai.pmnd.rs/docs/:slug*',
permanent: true,
},
{
source: '/react-spring',
destination: 'https://react-spring.io',
permanent: true,
},
{
source: '/react-spring/:slug*',
destination: 'https://react-spring.io/#:slug*',
permanent: true,
},
{
source: '/drei',
destination: 'https://github.com/pmndrs/drei#readme',
permanent: true,
},
{
source: '/drei/:slug*',
destination: 'https://github.com/pmndrs/drei#:slug*',
permanent: true,
},
]
},
}
// console.log('nextConfig=', nextConfig)

Expand Down
12 changes: 8 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $ rm -rf out; \
NEXT_PUBLIC_LIBNAME="React Three Fiber" \
BASE_PATH= \
DIST_DIR= \
OUTPUT=export \
npm run build && \
npx serve out
```
Expand All @@ -26,6 +27,7 @@ http://localhost:3000/getting-started/introduction
| `NEXT_PUBLIC_LIBNAME`\* | Library name | none |
| `BASE_PATH` | base path for the final URL | none |
| `DIST_DIR` | Path to the output folder | `out` |
| `OUTPUT` | Set to `export` for static `out`put | none |

\* Required

Expand All @@ -36,10 +38,11 @@ $ docker build -t pmndrs-docs .
```

```sh
$ cd ~/code/pmndrs/uikit
$ export BASE_PATH=/uikit; \
$ cd ~/code/pmndrs/react-three-fiber
$ export BASE_PATH=/react-three-fiber; \
export MDX=./docs; \
export NEXT_PUBLIC_LIBNAME="Uikit"; \
export NEXT_PUBLIC_LIBNAME="React Three Fiber"; \
export OUTPUT=export; \
\
rm -rf "$MDX/out"; \
docker run --rm --init -it \
Expand All @@ -48,8 +51,9 @@ $ export BASE_PATH=/uikit; \
-e DIST_DIR="$MDX/out$BASE_PATH" \
-e MDX \
-e NEXT_PUBLIC_LIBNAME \
-e OUTPUT \
pmndrs-docs npm run build && \
npx -y serve "$MDX/out"
```

Then go to http://localhost:3000/uikit/getting-started/introduction
Then go to http://localhost:3000/react-three-fiber/getting-started/introduction

0 comments on commit 896587a

Please sign in to comment.