I have already created a nextjs template with shadcn,and picked up some basic functionality of the website of https://ui.shadcn.com
Such as:
- design and layout
- Dark mode
⌘ K- mdx with contentlayer
Since the template was not clean, I decided to make a new one from scratch for sharing and deploy it to multiple platforms with SSG.
create project and migrate codebase from https://github.com/shadcn-ui/ui
clone the website repo of shadcn for reference
git clone https://github.com/shadcn-ui/ui --depth 1create-next-app
npx create-next-app@latestTo make same code deployed in these three platforms below, I have done some compat logic in next.config.js with environment variable
Build command
npx tsx --tsconfig ./tsconfig.scripts.json ./src/scripts/build-registry.mts && npx next buildEnvironment Variable
- NODE_VERSION=20.18.0
- PLATFORM=cloudflare pages
rename src/components/icons.tsx to another name, e.g. src/components/my-icons.tsx
Environment Variable
PLATFORM=github pages has been written in yml file of github workflow
Build command
tsx --tsconfig ./tsconfig.scripts.json ./src/scripts/build-registry.mts && next buildEnvironment Variable
PLATFORM=vercel
-
main branch is for the basic functionalities of the website, and share reusable code cross projects derived from this template.Furthermore, this branch is used for synchronizing the design system with shadcn-ui.
-
dynamic-config branch is for the dynamic configuration, especially for routes and metadata. For example, I will use doc page to display the blog post, the route should not be named as
/docs/[slug], but/blogs/[slug]instead for clarity.