# Monorepos

Run the layer inside the repository of Mirror or Vue Equipment, against the source rather than a published copy.

The layer runs on `@maas/mirror` and `@maas/vue-equipment`. Inside the repository of either one, the docs should run on the code next to them rather than on a release from npm. Two mechanisms make that work: peer dependencies for the packages, and aliases for the source.

## Packages

Both libraries are peer dependencies of the layer, so the docs app provides them. Declare the workspace package, and pnpm hands the layer the same copy.

```json [apps/docs/package.json]
{
  "dependencies": {
    "@maas/docs": "^0.1.0",
    "@maas/mirror": "workspace:*",
    "@maas/vue-equipment": "workspace:*"
  }
}
```

## Source

Nuxt resolves a module name through `alias` before it loads the module, and it installs a module once per resolved path. An alias for `@maas/vue-equipment/nuxt` therefore replaces the copy the layer registers instead of adding a second one.

```ts [apps/docs/nuxt.config.ts]
import { fileURLToPath } from 'node:url'

const packages = fileURLToPath(new URL('../../packages', import.meta.url))

export default defineNuxtConfig({
  extends: ['@maas/docs'],

  alias: {
    '@maas/vue-equipment/nuxt': `${packages}/nuxt/src/module`,
    '@maas/vue-equipment/plugins': `${packages}/plugins`,
    '@maas/vue-equipment/composables': `${packages}/composables`,
    '@maas/vue-equipment/utils': `${packages}/utils`,
  },

  vueEquipment: {
    plugins: true,
    composables: true,
  },
})
```

The same aliases reach the layer’s own imports, so the search palette and the drawer run on the plugin source as well. Your `vueEquipment` options take precedence over the plugins the layer registers.

## Tokens

To document the tokens the repository builds, point `docs.tokens` at its `.maas` directory. Demos that live in packages need their directories scanned by Tailwind and matched by `docs.previews`.

```ts [apps/docs/nuxt.config.ts]
export default defineNuxtConfig({
  extends: ['@maas/docs'],
  docs: {
    tokens: '../../.maas',
    sources: ['../../packages/plugins'],
    previews: ['../../packages/plugins/*/demo/*.vue'],
  },
})
```

## Pages

Pages documented next to their source join the collection through `source`.

```ts [apps/docs/content.config.ts]
import { fileURLToPath } from 'node:url'
import {
  defineContentConfig,
  defineDocsCollections,
} from '@maas/docs/content'

const plugins = fileURLToPath(new URL('../../packages/plugins', import.meta.url))

export default defineContentConfig({
  collections: defineDocsCollections({
    source: [
      { include: '0.overview/*.md' },
      {
        cwd: plugins,
        include: '*/index.md',
        prefix: '/1.plugins',
        exclude: ['**/node_modules/**'],
      },
    ],
  }),
})
```

::caution
Exclude `node_modules` from every source outside `content/`. The dev server watches each directory a source names, and `node_modules` links into the whole store.
::
