diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 042ac4a2..1591f2d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,10 @@ on: default: '/logo.png' base_path: type: string + github: + type: string + discord: + type: string jobs: build-job: @@ -52,6 +56,8 @@ jobs: -e NEXT_PUBLIC_URL \ -e ICON \ -e LOGO \ + -e GITHUB \ + -e DISCORD \ ghcr.io/pmndrs/docs:main npm run build env: BASE_PATH: ${{ steps.set-base-path.outputs.BASE_PATH }} @@ -64,6 +70,8 @@ jobs: NEXT_PUBLIC_URL: ${{ steps.configurepages.outputs.base_url }} ICON: '${{ inputs.icon }}' LOGO: '${{ inputs.logo }}' + GITHUB: '${{ inputs.github }}' + DISCORD: '${{ inputs.discord }}' - uses: actions/upload-pages-artifact@v3 with: diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 1438f758..bb523d78 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -30,6 +30,8 @@ jobs: --build-env NEXT_PUBLIC_URL="$VERCEL_PROJECT_PRODUCTION_URL" \ --build-env ICON="🖨️" \ --build-env LOGO=gutenberg.jpg \ + --build-env GITHUB="https://github.com/${{ github.repository }}" \ + --build-env DISCORD="${{ secrets.DISCORD }}" \ > deployment-url.txt echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01ad2a18..c30ae4c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,6 +32,8 @@ jobs: --build-env NEXT_PUBLIC_URL="$VERCEL_PROJECT_PRODUCTION_URL" \ --build-env ICON= \ --build-env LOGO=gutenberg.jpg \ + --build-env GITHUB="https://github.com/${{ github.repository }}" \ + --build-env DISCORD="${{ secrets.DISCORD }}" \ > deployment-url.txt echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT diff --git a/docs/getting-started/docker.mdx b/docs/getting-started/docker.mdx deleted file mode 100644 index 86929d3a..00000000 --- a/docs/getting-started/docker.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: Docker -description: Docker image generator -nav: 2 ---- - -```sh -$ docker build -t pmndrs-docs . -``` - -```sh -$ cd ~/code/pmndrs/react-three-fiber -$ ( - trap 'kill -9 0' SIGINT - - export _PORT=60141 - - export MDX=./docs - export NEXT_PUBLIC_LIBNAME="React Three Fiber" - export NEXT_PUBLIC_LIBNAME_SHORT="r3f" - export BASE_PATH= - export OUTPUT=export - export HOME_REDIRECT=/getting-started/introduction - export MDX_BASEURL=http://localhost:$_PORT - export EDIT_BASEURL= - export NEXT_PUBLIC_URL= - export ICON=🇨🇭 - export LOGO=/logo.png - - rm -rf "$MDX/out" - - docker run --rm --init -it \ - -v "$MDX":/app/docs \ - -e MDX \ - -e NEXT_PUBLIC_LIBNAME \ - -e BASE_PATH \ - -e DIST_DIR="$MDX/out$BASE_PATH" \ - -e OUTPUT \ - -e HOME_REDIRECT \ - -e MDX_BASEURL \ - -e EDIT_BASEURL \ - -e NEXT_PUBLIC_URL \ - -e ICON \ - -e LOGO \ - pmndrs-docs npm run build - - kill $(lsof -ti:"$_PORT") - npx serve $MDX -p $_PORT --no-port-switching --no-clipboard & - npx -y serve "$MDX/out" & - - wait -) -``` - -Then go to: http://localhost:3000 diff --git a/docs/getting-started/github-actions.mdx b/docs/getting-started/github-actions.mdx index 8dde443f..f928f58d 100644 --- a/docs/getting-started/github-actions.mdx +++ b/docs/getting-started/github-actions.mdx @@ -15,6 +15,8 @@ uses: pmndrs/docs/.github/workflows/build.yml@main home_redirect: '/getting-started/introduction' icon: '🇨🇭' logo: '/logo.png' + github: 'https://github.com/pmndrs/react-three-fiber' + discord: 'https://discord.com/channels/740090768164651008/740093168770613279' ``` See [`pmndrs/react-three-fiber/.github/workflows/docs.yml`](https://github.com/pmndrs/react-three-fiber/blob/master/.github/workflows/docs.yml) for an example implementation. diff --git a/docs/getting-started/introduction.mdx b/docs/getting-started/introduction.mdx index abab25d1..c5682df7 100644 --- a/docs/getting-started/introduction.mdx +++ b/docs/getting-started/introduction.mdx @@ -30,6 +30,8 @@ $ npm ci | `NEXT_PUBLIC_URL` | Final URL of the published website | `https://pmndrs.github.io/react-three-fiber` | | `ICON` | Emoji or image to use as (fav)icon (path local to `MDX`) | `🇨🇭` or `/icon.png` or `/favicon.ico` | | `LOGO` | Logo src/path (either FQURL or local to `MDX` path) | `/logo.png` or `https://worldvectorlogo.com/r3f.png` | +| `GITHUB` | Github URL | `https://github.com/pmndrs/react-three-fiber` | +| `DISCORD` | Discord URL | `https://discord.com/channels/740090768164651008/740093168770613279` | \* Required @@ -75,6 +77,8 @@ $ ( export NEXT_PUBLIC_URL= export ICON= export LOGO=gutenberg.jpg + export GITHUB=https://github.com/pmndrs/docs + export DISCORD=https://discord.com/channels/740090768164651008/1264328004172255393 kill $(lsof -ti:"$_PORT") npx serve $MDX -p $_PORT --no-port-switching --no-clipboard & @@ -111,6 +115,8 @@ $ ( export NEXT_PUBLIC_URL= export ICON= export LOGO=gutenberg.jpg + export GITHUB=https://github.com/pmndrs/docs + export DISCORD=https://discord.com/channels/740090768164651008/1264328004172255393 npm run build @@ -123,3 +129,59 @@ $ ( ``` http://localhost:3000 + +## Docker + +```sh +$ docker build -t pmndrs-docs . +``` + +```sh +$ cd ~/code/pmndrs/react-three-fiber +$ ( + trap 'kill -9 0' SIGINT + + export _PORT=60141 + + export MDX=./docs + export NEXT_PUBLIC_LIBNAME="React Three Fiber" + export NEXT_PUBLIC_LIBNAME_SHORT="r3f" + export BASE_PATH= + export OUTPUT=export + export HOME_REDIRECT=/getting-started/introduction + export MDX_BASEURL=http://localhost:$_PORT + export EDIT_BASEURL= + export NEXT_PUBLIC_URL= + export ICON=🇨🇭 + export LOGO=/logo.png + export GITHUB=https://github.com/pmndrs/react-three-fiber + export DISCORD=https://discord.com/channels/740090768164651008/740093168770613279 + + rm -rf "$MDX/out" + + docker run --rm --init -it \ + -v "$MDX":/app/docs \ + -e MDX \ + -e NEXT_PUBLIC_LIBNAME \ + -e BASE_PATH \ + -e DIST_DIR="$MDX/out$BASE_PATH" \ + -e OUTPUT \ + -e HOME_REDIRECT \ + -e MDX_BASEURL \ + -e EDIT_BASEURL \ + -e NEXT_PUBLIC_URL \ + -e ICON \ + -e LOGO \ + -e GITHUB \ + -e DISCORD \ + pmndrs-docs npm run build + + kill $(lsof -ti:"$_PORT") + npx serve $MDX -p $_PORT --no-port-switching --no-clipboard & + npx -y serve "$MDX/out" & + + wait +) +``` + +Then go to: http://localhost:3000 diff --git a/src/app/[...slug]/Menu.tsx b/src/app/[...slug]/Menu.tsx index f0bcd76a..daec2088 100644 --- a/src/app/[...slug]/Menu.tsx +++ b/src/app/[...slug]/Menu.tsx @@ -35,7 +35,7 @@ export function Menu({
{header}
- + +
+ {process.env.GITHUB && ( + + + + )} + {process.env.DISCORD && ( + + + + )} + +
} nav={ diff --git a/src/components/ToggleTheme.tsx b/src/components/ToggleTheme.tsx index a68cddac..1ba98605 100644 --- a/src/components/ToggleTheme.tsx +++ b/src/components/ToggleTheme.tsx @@ -4,8 +4,10 @@ import * as React from 'react' import { CiDark, CiLight } from 'react-icons/ci' import { useTheme } from 'next-themes' import Image from 'next/image' +import cn from '@/lib/cn' +import { ComponentProps } from 'react' -const ToggleTheme = () => { +const ToggleTheme = (props: ComponentProps<'button'>) => { const { setTheme, resolvedTheme } = useTheme() const [isDark, setIsDark] = React.useState(undefined) @@ -25,7 +27,7 @@ const ToggleTheme = () => { return (