Hexta AIHexta AI

Workspace

Use Hexta MDX in multiple workspace.

Overview

Workspace in Hexta MDX, refers to an independent project with its own config and content.

index.mdx
test.mdx
source.config.ts
welcome.mdx
source.config.ts

Good to Know

Hexta 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:

source.config.ts
import { defineConfig } from 'hexta-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:

  • cwd refers 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:

lib/source.ts
import { docs } from 'collections/my-workspace/server';

The output location of root workspace is not changed.

To integrate multi-source in Hexta AI:

lib/source.ts
import { loader } from 'hexta-core/source';
import { docs } from 'collections/server';
import * as MyWorkspace from 'collections/my-workspace/server';

export const source = loader(
  {
    root: docs.toHextaSource(),
    'my-workspace': MyWorkspace.docs.toHextaSource(),
  },
  {
    baseUrl: '/docs',
  },
);

When to Use

In some setups, you might have multiple Hexta MDX configs with their own content directory.

With workspaces, you can integrate them into one Hexta 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 A, and other repos be T_n
  • for each repo T_n:
    • T_n has A as a git submodule.
    • T_n defines its own config source.config.ts and work independently.
    • when a commit is made to the content in T_n, it triggers a GitHub action (or CI), which creates a new deployment on A.
  • when a deployment is triggered on A:
    • Hexta MDX handles each T_n as a workspace.
    • each workspace generates its own collection entries, e.g. collections/{repo}/server.
    • Hexta AI loader() integrate multiple sources into one.

How is this guide?