1 # Book Style Guide
2
3 The `book` project (`www/apps/book/`) is the Medusa learning platform covering framework fundamentals, architecture, configurations, and how-to guides for building with Medusa.
4
5 ## Content Structure
6
7 ### Page structure
8
9 Every book page follows this pattern:
10
11 ```mdx
12 export const metadata = {
13 title: `${pageNumber} Topic Title`,
14 }
15
16 # {metadata.title}
17
18 In this chapter, you'll learn about <topic>.
19
20 ## What is <Topic>?
21
22 [Conceptual explanation — 1-3 paragraphs]
23
24 <Note title="Don't use <Topic> if" type="error">
25 - Condition A → use [alternative]() instead
26 - Condition B → use [alternative]() instead
27 </Note>
28
29 ---
30
31 ## How to Create a <Topic>
32
33 [Step-by-step implementation with code examples]
34
35 ### Test the <Topic>
36
37 [Minimal test steps]
38
39 ---
40
41 ## Example: <Realistic Use Case>
42
43 [Real-world example with full code]
44 ```
45
46 ### Directory structure and page placement
47
48 | Content type | Directory |
49 |---|---|
50 | Core concepts (modules, workflows, events, etc.) | `app/learn/fundamentals/` |
51 | Configuration files (medusa-config, pnpm, tsconfig) | `app/learn/configurations/` |
52 | Custom features, plugins, extend behavior | `app/learn/customization/` |
53 | Deployment, Docker, hosting | `app/learn/deployment/` |
54 | Testing, debugging, logging | `app/learn/debugging-and-testing/` |
55 | Frontend/storefront integration | `app/learn/storefront-development/` |
56
57 ### Adding a new page
58
59 1. Create the file at the correct path:
60 ```
61 www/apps/book/app/learn/<section>/<topic>/page.mdx
62 ```
63
64 2. Add the page to `www/apps/book/sidebar.mjs`:
65 ```javascript
66 {
67 type: "link",
68 path: "/learn/<section>/<topic>",
69 title: "Topic Title",
70 }
71 ```
72
73 3. The `${pageNumber}` in the title is auto-populated by `yarn prep` — always include it.
74
75 ## Writing Style
76
77 - **Second person**: "You create a workflow..." not "We create..."
78 - **Imperative for steps**: "Create the file `src/workflows/my-workflow.ts`..."
79 - **Present tense**: "The workflow runs..." not "The workflow will run..."
80 - **Concrete examples**: Every concept must have at least one working TypeScript code example
81 - **No jargon without explanation**: Define terms on first use
82
83 ## Code Examples
84
85 Always include TypeScript examples. Follow the Medusa import patterns exactly:
86
87 ```ts title="src/workflows/my-workflow.ts"
88 import {
89 createWorkflow,
90 WorkflowResponse,
91 createStep,
92 StepResponse,
93 } from "@medusajs/framework/workflows-sdk"
94 import { Modules } from "@medusajs/framework/utils"
95 import type { MedusaContainer } from "@medusajs/framework/types"
96 ```
97
98 Use highlights to call attention to key lines in the code (see `mdx-patterns.md`).
99
100 ## When to update book
101
102 - A new framework feature is added (new decorator, new utility, new config option)
103 - A core concept changes its API or behavior (workflow API, module API, event system)
104 - A configuration option is added to `medusa-config`
105 - A concept referenced in existing chapters changes behavior
106 - Admin widget zones or UI route extension API changes (update `customization/` chapters)
107
108 ## What NOT to add to book
109
110 - Commerce-module-specific documentation (product, order, cart) → goes in `resources`
111 - Step-by-step integration tutorials → goes in `resources`
112 - Generated API references → never add to book
113 - User-facing admin UI instructions → goes in `user-guide`