tokio-rs / website

Website for the Tokio project
https://tokio.rs
MIT License
228 stars 329 forks source link

Update to Next.js 13, React 18 #688

Closed luooooob closed 1 year ago

luooooob commented 1 year ago

-----update----


The last few versions of Next.js have made a lot of progress, so I tried to upgrade version 9.4 to 13, React, Typescript and markdown related libraries were also upgraded together because these versions are really old, the main work is as follows

  1. the new version of Next has requirements for extra js and css files, and the way to write <Link /> has also changed, just follow the upgrade guide to do this

  2. package lock.json has been upgraded to the latest algorithm, so the number of commit lines seems a bit high. I highly recommend switching to pnpm, it's really much faster than npm.

  3. react-markdown has been upgraded a lot, the direct insert HTML function has been removed, so you need to introduce the new rehype-raw plugin. slug function also has a very good plugin rehype-slug can be used, no need to maintain some bad code yourself

  4. the only breaking change that needs your attention is that the old warning and info directive syntax is not compatible with the new version of the renderer, the syntax is too specific and there is no way to find a replacement.

[[warning]]
| this is warning
| this is warning

I found that Github is experimenting with a new syntax based on blockquote, and it's easy to implement, so I changed it to this implementation

> **warning**
> this is warning
> this is warning

The rendered result is still exactly the same as the old one, but you need to pay attention to writing new documents later. The old document has been replaced by a global search

  1. Next now supports esm syntax, so you don't need to stuff generate-rss-feed.js into webpack to make a package, just node ./script/generate-rss-feed.js will work, I've tried it and it works.

  2. almost all places look exactly the same as the old one, just optimized code.I saw a PR for migrating to docusaurus, you don't seem to like it, but this project with too many outdated dependencies is really annoying, I hope my work can help you

luooooob commented 1 year ago

Will the pr generate a preview here? that would be a bit awesome. The build command should not change. You may need to upgrade the node version of the deployment environment.

Darksonn commented 1 year ago

The netlify/tokio/deploy-preview CI step should provide a preview.

luooooob commented 1 year ago

I found it possible to render Markdown at build time, and now the client is much lighter

There is still a lot of work to be done to make the client lighter and simplify the code, I can still work on it if this update is approved