website icon indicating copy to clipboard operation
website copied to clipboard

Docusaurus v2

Open harish-sethuraman opened this issue 3 years ago • 21 comments

This PR will contain changes needed for docusaurus v2. Use this PR for reviews and tracking file changes. I'll modify the existing site rather than creating a new copy of site (since this will be hard for tracking changes).

Related PRs:

  1. https://github.com/harish-sethuraman/website/pull/1
  2. https://github.com/harish-sethuraman/website/pull/2
  3. https://github.com/harish-sethuraman/website/pull/3
  4. https://github.com/harish-sethuraman/website/pull/4
  5. https://github.com/harish-sethuraman/website/pull/5
  6. https://github.com/harish-sethuraman/website/pull/6
  7. https://github.com/harish-sethuraman/website/pull/9

Builds succeed properly and pages work fine. Please report bugs if any.

harish-sethuraman avatar Feb 08 '22 03:02 harish-sethuraman

❌ Deploy Preview for babel failed. Built without sensitive environment variables

🔨 Explore the source changes: 37e359f28473022115dda49dab1fc4af5346757b

🔍 Inspect the deploy log: https://app.netlify.com/sites/babel/deploys/6233677156259800085f3b92

netlify[bot] avatar Feb 08 '22 03:02 netlify[bot]

@nicolo-ribaudo or @hzoo Can you help setup a netlify build for a new branch v2 with node version >= 14? (https://docusaurus.io/docs/installation#requirements)

harish-sethuraman avatar Feb 08 '22 13:02 harish-sethuraman

@harish-sethuraman Thanks for the head-up. I specified the node version to 16 and let's see if that works.

JLHwung avatar Feb 08 '22 16:02 JLHwung

Nice 😄

harish-sethuraman avatar Feb 08 '22 16:02 harish-sethuraman

Seems like with docusaurus v2 https://docusaurus.io/docs/migration/manual#update-references-to-the-build-directory the build directories have changed and we have to tweak the build directory to build rather than build/babel.

harish-sethuraman avatar Feb 08 '22 17:02 harish-sethuraman

It works fine now but we might want to change the build directory to build instead of build/babel. If anyone changes build dirs you can revert https://github.com/babel/website/pull/2622/commits/c824b95b37bbf41657bceeb87e527b28f63c0722 and everything should work fine.

For now we have main page working and docs working as well.... I'll try to land other pages one at a time 😅

harish-sethuraman avatar Feb 08 '22 17:02 harish-sethuraman

We have some customized stylesheets: https://github.com/babel/website/tree/main/website/static/css, it would be great if we can adapt them to docusaurus v2.

JLHwung avatar Feb 08 '22 19:02 JLHwung

We have some customized stylesheets: https://github.com/babel/website/tree/main/website/static/css, it would be great if we can adapt them to docusaurus v2.

Will look into it tomorrow... Seems like the class names have changed...

harish-sethuraman avatar Feb 08 '22 19:02 harish-sethuraman

The design for the top navigation has been changed in the docusaurus v2. Now there is a ham menu (in mobile) that pops a modal from the left instead of wrapping the menu items in the next line and adding a horizontal scroll :(

Shall we leave it as such for mobile view or should we try to bring back the older top nav?

harish-sethuraman avatar Feb 09 '22 11:02 harish-sethuraman

There are only 2 pages remaining the repl page and setup page. Other than that I've migrated the existing pages to docusaurus v2. We might want to revamp pages for dark mode as well :)

harish-sethuraman avatar Feb 10 '22 17:02 harish-sethuraman

The REPL is complex enough that we could leave it outside of docusaurus, just as a static page. Does docusaurus v2 support adding external links to the header?

Shall we leave it as such for mobile view or should we try to bring back the older top nav?

The new one looks ok to me.


It looks like this update breaks the custom components that we have (defined using vanilla JavaScript, not with React): the demo in the homepage doesn't work, and the editors at aren't interactive. Is it possible to make them work without rewriting them to React (codemirror doesn't integrate well with React, it works way better when it can fully manage its dom elements).

nicolo-ribaudo avatar Feb 11 '22 13:02 nicolo-ribaudo

The REPL is complex enough that we could leave it outside of docusaurus, just as a static page. Does docusaurus v2 support adding external links to the header?

Yes it does. Shall I add a folder in the build and add static html to add repl scripts and style sheets? 

It looks like this update breaks the custom components that we have (defined using vanilla JavaScript, not with React): the demo in the homepage doesn't work, and the editors at aren't interactive. Is it possible to make them work without rewriting them to React (codemirror doesn't integrate well with React, it works way better when it can fully manage its dom elements).

Will look into it

harish-sethuraman avatar Feb 11 '22 13:02 harish-sethuraman

Shall I add a folder in the build and add static html to add repl scripts and style sheets?

Yes please! We can iterate in a follow-up PR to make it part of the main build, but there is no need to do it now (also I kinda want to rewrite the Repl state management, which is currently quite complex, with something like xstate).

nicolo-ribaudo avatar Feb 11 '22 13:02 nicolo-ribaudo

@nicolo-ribaudo we might not be able to move repl as a static page. It has navbar which comes from docusaurus. If we want to move the repl page separately outside of docusaurus. We have to either remove the topnav or add the css for the navbar and functionality for dark mode toggle (languages dropdown if we plan to add languages too)

harish-sethuraman avatar Feb 12 '22 16:02 harish-sethuraman

@nicolo-ribaudo thoughts? 👆

harish-sethuraman avatar Feb 14 '22 18:02 harish-sethuraman

we might not be able to move repl as a static page. It has a navbar which comes from docusaurus. If we want to move the repl page separately outside of docusaurus. We have to either remove the top nav or add the CSS for the navbar and functionality for dark mode toggle (languages dropdown if we plan to add languages too)

@JLHwung @nicolo-ribaudo Any updates on this?

Or shall I move them to a separate page with basic nav layout (without dark mode toggle ? )

harish-sethuraman avatar Feb 22 '22 17:02 harish-sethuraman

I tried porting repl to docusaurus v2: https://github.com/JLHwung/babel-website/commit/60c4a4ab495c5495dff39cfddb88c95a1abefc56 Currently it works only on Safari, both Chrome and Firefox complains that CodeMirror is not defined, which should not happen if the scripts are loaded in correct order.

The REPL is a React component which injects a #root DOM element and hands to external scripts for everything else, I think we don't have to exclude REPL.

JLHwung avatar Feb 22 '22 22:02 JLHwung

@JLHwung I ported repl page to v2 https://deploy-preview-7--gracious-ardinghelli-43e471.netlify.app/repl/ https://github.com/harish-sethuraman/website/pull/7

We are not allowed to add scripts via scripts tag in docusaurus v2 that is why it doesn't detect codeMirror.

  • We might probably want to extract the entire repl page into separate HTML and route the /repl to that static page that will contain nav html and scripts for that particular page. While doing so we might have to write some functionalities for the nav such as closing and opening for mobile view, dark mode toggle and dropdowns (languages and versions if we decide to add them). Would that be good or can we better have a basic nav that routes to other main pages alone?

harish-sethuraman avatar Feb 23 '22 03:02 harish-sethuraman

@harish-sethuraman The REPL port looks promising. CodeMirrors seems working, too. Do we still need to extract the page?

JLHwung avatar Mar 03 '22 19:03 JLHwung

@JLHwung Yea we have to extract the page since the scripts used for repl is being injected into all pages. https://github.com/harish-sethuraman/website/pull/9 I've actually chunked out the page 😅. I still have to add CSS and navbar functionality alone.

harish-sethuraman avatar Mar 04 '22 02:03 harish-sethuraman

I've extracted the REPL page separately with htmlwebpackplugin. Can someone let me know if it is okay? URL: https://deploy-preview-2622--babel.netlify.app/repl @JLHwung @nicolo-ribaudo @hzoo

harish-sethuraman avatar Mar 12 '22 05:03 harish-sethuraman