Workspace
Use Hanzo Docs MDX in multiple workspace.
Overview
Workspace in Hanzo Docs MDX, refers to an independent project with its own config and content.
Good to Know
Hanzo Docs MDX Workspace is not limited to the traditional meaning of workspace in package managers.
They do not need to have its own package.json, only a config file is needed.
To define a workspace, add:
import { defineConfig } from '@hanzo/docs/mdx/config';
export default defineConfig({
workspaces: {
'my-workspace': {
dir: 'my-workspace',
config: await import('./my-workspace/source.config.ts'),
},
},
});When writing content in a workspace, note that:
cwdrefers to the current workspace directory.- configs will not inherit, workspaces are always independent.
By running dev or build server, you should see collection entries from all workspaces to be generated.
Accessing Collections
You can access the generated files of a workspace at .source/{workspace}/*. For example:
import { docs } from '@hanzo/docs-mdx:collections/my-workspace/server';The output location of root workspace is not changed.
To integrate multiple sources in Hanzo Docs, use multiple:
import { loader, multiple } from '@hanzo/docs/core/source';
import { docs } from '@hanzo/docs-mdx:collections/server';
import * as MyWorkspace from '@hanzo/docs-mdx:collections/my-workspace/server';
export const source = loader(
multiple({
root: docs.toHanzo DocsSource(),
'my-workspace': MyWorkspace.docs.toHanzo DocsSource(),
}),
{
baseUrl: '/docs',
},
);When to Use
In some setups, you might have multiple Hanzo Docs MDX configs with their own content directory.
With workspaces, you can integrate them into one Hanzo Docs MDX config, and access all collections of each workspace.
This is crucial for use cases like storing content across multiple repos, a simplified setup would be:
- let your main docs repo be , and other repos be
- for each repo :
- has as a git submodule.
- defines its own config
source.config.tsand work independently. - when a commit is made to the content in , it triggers a GitHub action (or CI), which creates a new deployment on .
- when a deployment is triggered on :
- Hanzo Docs MDX handles each as a workspace.
- each workspace generates its own collection entries, e.g.
@hanzo/docs-mdx:collections/{repo}/server. - Hanzo Docs
loader()integrate multiple sources into one.
How is this guide?
Last updated on
