Status: Accepted
Context
In the initial prototype of web-unified-docs,.mdx content files were located directly in the public/ directory.
This decision followed ADR 002, which established that MDX transforms should be applied during the prebuild script. With transforms running at build time, the files in the repository (the source files) are different from the files that should be served (the transformed files). Storing source files in public/ implies they are the files being served — which is no longer true.
This created a workflow problem. With source files already in public/, applying transforms in place would modify tracked files, disrupting local authoring workflows where changes are tracked in git. The alternatives were unintuitive:
- Modify files in place for deploy preview and production, but skip this for local development — creating environment-specific behavior
- Copy files to a subdirectory of
public/before transforming — but then both raw and transformed content would be publicly accessible
Decision
Authored.mdx content lives in a content/ directory at the root of the repository.
When the prebuild script runs MDX transforms, it reads from content/ and writes transformed output to public/content/. The public/content/ output directory mirrors the structure of content/ and is excluded from version control.
Directory structure:
What is not decided here
The internal structure ofcontent/ is not finalized by this ADR. The directory structure within content/ was inherited from the prototype and should not be interpreted as a deliberate or permanent design. A separate decision will be needed on how to organize content/ and that decision will be made in collaboration with content authors.
The location of images and other assets is not decided here. At the time this ADR was written, there was no clear need to process images before serving them, so images remained in public/assets/. A separate decision will be needed on how to organize versioned images and assets.
Consequences
Positive consequences:- A consistent and intuitive MDX transformation workflow works the same way across local development, deploy preview, and production builds. There is no environment-specific behavior.
- Content authors have a clearly marked and isolated directory (
content/) where.mdxsource files should be written. Thepublic/content/directory is clearly build output. - The separation between source and output makes it easy to reason about what is tracked in git versus what is generated.
- The prebuild script can safely write transformed files to
public/content/without touching version-controlled source files, even during local development.
- Original authored MDX files are no longer accessible through the Vercel CDN. This is not a problem in practice — dev-portal needs transformed content, not raw authored source. But it is a change from the prototype behavior.
- The
public/content/andpublic/assets/directories must be regenerated whenever the prebuild runs. They are listed in.gitignoreand in themake cleancommand, which removes these directories when stopping the local preview. - Assets (images and other binary files) are handled separately from MDX content. The current approach copies assets from
content/<product>/<version>/img/topublic/assets/<product>/<version>/during the prebuild. The long-term approach to shared versus versioned assets is a separate open question.