From 896587ade7adf6abd58fbb900d356d19f00b5ba1 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 11 Aug 2024 00:31:40 +0200 Subject: [PATCH] OUTPUT --- .github/workflows/build.yml | 1 + next.config.mjs | 101 ++++++++++++++++++------------------ readme.md | 12 +++-- 3 files changed, 60 insertions(+), 54 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a05fe3c..52ee50ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }} diff --git a/next.config.mjs b/next.config.mjs index 18f5ff03..4f6330e4 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -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 = { @@ -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) diff --git a/readme.md b/readme.md index 2af1cbb0..c37544cc 100644 --- a/readme.md +++ b/readme.md @@ -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 ``` @@ -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 @@ -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 \ @@ -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