Giter Site home page Giter Site logo

Support Partial Build about docusaurus HOT 7 CLOSED

heywalter avatar heywalter commented on April 28, 2024
Support Partial Build

from docusaurus.

Comments (7)

slorber avatar slorber commented on April 28, 2024 1

@heywalter you could simply have one config file for both sites, and use env variables to toggle respective plugins.

MODE=blog docusaurus build
MODE=docs docusaurus build
const mode = process.env.MODE;

// Note you can also keep things on the same domain, and use different baseUrls for each plugin
const url = mode === "docs" ? "https://docs.myDomain.com" : "https://blog.myDomain.com"

const presetConfig = {
  docs: mode === "docs" ? yourDocsOptions : false,
  blog: mode === "blog" ? yourBlogOptions : false,
}

For more complex cases, and avoiding a single messy config file, you could also use different config files:

docusaurus build --config docusaurus.blog.config.js
docusaurus build --config docusaurus.docs.config.js

And you can put shared Docusaurus config in a docusaurus.shared.config.js.

For example if you want a consistent navbar, you can put the themeConfig.navbar in that shared config file

from docusaurus.

heywalter avatar heywalter commented on April 28, 2024 1

Got it, thanks for your help.

from docusaurus.

slorber avatar slorber commented on April 28, 2024 1

Great that you find it helpful.

I'm going to close this issue because "partial build" is kind of abstract to me.

But if someone can define precisely what it is and how this should be implemented, I'll remain open to the discussion and we'll eventually reopen.

Thanks

from docusaurus.

slorber avatar slorber commented on April 28, 2024

What you ask here is quite complicated to build, because in the end the Docusaurus app must be one single-page application.

We should be able to transition from a doc to a blog post with an SPA soft navigation, which means the SPA router routes should be shared between all the plugin instances that you want to build. This also means we probably need a command to build the "shell/container" that will be able to receive and plug the host application slices (plugin instances).

And when redeploying one plugin instance routes, it shouldn't break the code that already exists and is deployed.

Webpakc Module Federation can probably support that, however, it's not a simple subject: https://webpack.js.org/concepts/module-federation/

Of course there are other problems to consider like how we generate global things in postBuild like the sitemap.xml, referencing all the urls of a given site. We should then update

Also, it would be hard to detect broken links across plugin instances that have not be built.


It's not clear to me how you see yourself hosting this in practice, can you describe this more precisely?

  • What is your site url (or urls if many)
  • Where is this hosted? Self-hosted? CDN?
  • What CI commands do you run to host it the first time
  • What CI commands do run to redeploy a plugin instance
  • How is your sitemap updated on redeploy?

Really, this looks complicated to me and the source of many problems. I'd rather spend time optimizing the build rather than implementing this, if the goal is only to deploy faster.

Note that another solution would be to "shard" your site, and actually split it into multiple smaller Docusaurus sites. You don't need to have 2 Docusaurus site folders for that, and can use env variables in a single config file to build your docs and your blog as separate standalone sites.

INSTANCE=docs docusaurus build
INSTANCE=blog docusaurus build

Note we already do that for i18n: each locale is a standalone site, and you can deploy each localized site independently, using multiple strategies (all locales on same domain or one subdomain per locale). The same can be applied to docs/blog:

https://docusaurus.io/docs/i18n/tutorial#deploy-your-site

from docusaurus.

heywalter avatar heywalter commented on April 28, 2024

Our current product documentation is maintained locally, covering nearly 20 products, each with its own version. In total, there are around 10,000 Markdown files, and the HTML files generated by scripts amount to nearly 8GB.

We plan to use Docusaurus for managing and publishing our external product documentation. We haven't started the actual deployment and migration yet, so there are no URLs or CI configuration details to share at the moment. We anticipate adopting a self-hosted approach.

Our current idea is to centralize the documentation of all products on one site for publication, but this raises concerns about update performance. I'm unsure about the build performance of Docusaurus, hence my concern upon seeing related issues here.

I wonder if there's a more efficient way to manage documentation in this scenario? Thanks.

from docusaurus.

slorber avatar slorber commented on April 28, 2024

Docusaurus is not the fastest SSG tool out there, and is slower than some alternatives in Rust or Go, but the experience for the end user is also IMHO better because it's an SPA that has a fluid soft navigation experience, preserving UI state when navigation. This kind of experience is more costly to build in general because we are building an SPA app, not just individual standalone HTML pages.

Now if you have 20 products, why not splitting your docs in 20 smaller sites?
It does not mean that the 20 sites should be independently coded: you can share most of the config, theme, CSS and everything, so that technically all the 20 sites kind of look the same, and it's possible to link from one site to another quite easily.

Take this as an example:

Those 2 are distinct Docusaurus sites sharing the same navbar/footer/layout/UI/CSS/infrastructure.

You can see that because when navigating from plugin to widget, it's a real browser navigation and not an SPA soft navigation.

This enables Figma to be able to deploy just the plugin site without redeploying the widget site.

from docusaurus.

heywalter avatar heywalter commented on April 28, 2024

This seems like a great idea, thank you. Could I ask for the specific implementation steps? For example, how to maintain a consistent navigation bar after splitting, and how to configure the docusaurus.config.js. Thank you.

from docusaurus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.