I'm so proud that I as a newbie finally got through this... .
What challenges did you encounter, and how did you overcome them?Since there are multiple pages with a same <header> component, and a data.json
to fetch and render, I tried to use NextJS for the first time instead of plain HTML/CSS/Javascript as I previously did. The struggling are mostly from the framework and deployment.
I learned about React, NextJs, Typescript, TailwindCSS.
Some records of the tough journey I've been through:
- cannot get tailwindCSS work well, and I finally realized that's the version discrepancy. It is tailwind v3.x.x from
'npm install next@latest react@latest react-dom@latest'
, and I unrecognizely updated it to tailwind v4.x.x in order to add some theme style in the globals.css following the tailwind website's instruction (using latest version). The syntax of these two big versions were quite different: @layer, @theme, @tailwind, @import 'tailwindcss', @theme, @layer utility, new@tailwindcss/postcss
package... . Also tried hard to dynamically change the background-image url inbg-[url()]
with Object values, but it seems unfeasible and I gave up in the end. - typing of typescript.
- static export of the NextJS. I used server component
searchParams
props to switch the different small tabs in the main page, which is a dynamic API and therefore cannot make static export. Alternatively, I shifted to use a client component usinguseSearchParams()
and made static export work. - deployment to GitHub pages. I need to rename the
/out
directories built from NextJS to/docs
to match the GitHub page subbranch deployment. After that, there are still many small things to configure: set basePath to my GitHub repo name in next.config.ts, add/<my-github-repo-name>
prefix to the <Image> and the background-image url, add.nojekyll
file at the/docs/
directory to make GitHub page to provide files in/docs/_next
directory.