|
1
|
# Resources Style Guide |
|
2
|
|
|
3
|
The `resources` project (`www/apps/resources/`) covers commerce modules, how-to guides, recipes, integrations, and JS SDK documentation. |
|
4
|
|
|
5
|
## Content Types and Locations |
|
6
|
|
|
7
|
| Content type | Path | |
|
8
|
|---|---| |
|
9
|
| Commerce module overview | `app/commerce-modules/<module>/page.mdx` | |
|
10
|
| Module sub-topics | `app/commerce-modules/<module>/<topic>/page.mdx` | |
|
11
|
| Infrastructure modules | `app/infrastructure-modules/<module>/page.mdx` | |
|
12
|
| How-to guides | `app/how-to-tutorials/<topic>/page.mdx` | |
|
13
|
| Recipes (solution guides) | `app/recipes/<topic>/page.mdx` | |
|
14
|
| JS SDK guides | `app/js-sdk/<topic>/page.mdx` | |
|
15
|
| Integrations | `app/integrations/<name>/page.mdx` | |
|
16
|
|
|
17
|
> **CRITICAL:** Never create or edit files under `references/`. These are auto-generated from TSDocs. Only link to them. |
|
18
|
|
|
19
|
## Module Overview Page Structure |
|
20
|
|
|
21
|
~~~mdx |
|
22
|
--- |
|
23
|
generate_toc: true |
|
24
|
--- |
|
25
|
|
|
26
|
import { CodeTabs, CodeTab } from "docs-ui" |
|
27
|
|
|
28
|
export const metadata = { |
|
29
|
title: `<Module Name> Module`, |
|
30
|
} |
|
31
|
|
|
32
|
# {metadata.title} |
|
33
|
|
|
34
|
In this section of the documentation, you will find resources to learn more |
|
35
|
about the <Module Name> Module and how to use it in your application. |
|
36
|
|
|
37
|
<Note title="Looking for no-code docs?"> |
|
38
|
|
|
39
|
Refer to the [Medusa Admin User Guide](!user-guide!/<path>) to learn how to |
|
40
|
manage <items> using the dashboard. |
|
41
|
|
|
42
|
</Note> |
|
43
|
|
|
44
|
Medusa has <domain> features available out-of-the-box through the |
|
45
|
<Module Name> Module. A [module](!docs!/learn/fundamentals/modules) is a |
|
46
|
standalone package that provides features for a single domain. |
|
47
|
|
|
48
|
## <Module Name> Features |
|
49
|
|
|
50
|
- [Feature A](/references/<module>/models/ModelA): Description of feature A. |
|
51
|
- [Feature B](./sub-topic/page.mdx): Description of feature B. |
|
52
|
|
|
53
|
--- |
|
54
|
|
|
55
|
## How to Use the <Module Name> Module |
|
56
|
|
|
57
|
In your Medusa application, you build flows around Commerce Modules. A flow is |
|
58
|
built as a [Workflow](!docs!/learn/fundamentals/workflows). |
|
59
|
|
|
60
|
For example: |
|
61
|
|
|
62
|
export const highlights = [ |
|
63
|
["12", "Modules.<MODULE>", "Resolve the module in a step."] |
|
64
|
] |
|
65
|
|
|
66
|
```ts title="src/workflows/example.ts" highlights={highlights} |
|
67
|
import { |
|
68
|
createWorkflow, |
|
69
|
WorkflowResponse, |
|
70
|
createStep, |
|
71
|
StepResponse, |
|
72
|
} from "@medusajs/framework/workflows-sdk" |
|
73
|
import { Modules } from "@medusajs/framework/utils" |
|
74
|
|
|
75
|
const myStep = createStep( |
|
76
|
"my-step", |
|
77
|
async (input, { container }) => { |
|
78
|
const moduleService = container.resolve(Modules.<MODULE>) |
|
79
|
// ... |
|
80
|
return new StepResponse(result) |
|
81
|
} |
|
82
|
) |
|
83
|
``` |
|
84
|
~~~ |
|
85
|
|
|
86
|
## How-to Guide Structure |
|
87
|
|
|
88
|
~~~mdx |
|
89
|
import { Prerequisites } from "docs-ui" |
|
90
|
|
|
91
|
export const metadata = { |
|
92
|
title: `How to <Task>`, |
|
93
|
} |
|
94
|
|
|
95
|
# {metadata.title} |
|
96
|
|
|
97
|
In this guide, you'll learn how to <task description>. |
|
98
|
|
|
99
|
<Prerequisites |
|
100
|
items={[ |
|
101
|
{ |
|
102
|
text: "Medusa application set up", |
|
103
|
link: "!docs!/learn/installation", |
|
104
|
}, |
|
105
|
]} |
|
106
|
/> |
|
107
|
|
|
108
|
## Step 1: <First Step> |
|
109
|
|
|
110
|
[Explanation of what and why] |
|
111
|
|
|
112
|
```ts title="src/..." |
|
113
|
// code |
|
114
|
``` |
|
115
|
|
|
116
|
## Step 2: <Second Step> |
|
117
|
|
|
118
|
... |
|
119
|
|
|
120
|
## Summary |
|
121
|
|
|
122
|
You've learned how to <task>. You can now... |
|
123
|
~~~ |
|
124
|
|
|
125
|
## Sidebar Configuration |
|
126
|
|
|
127
|
Each module has a dedicated sidebar file. When adding a new page: |
|
128
|
|
|
129
|
1. Find the relevant sidebar file in `www/apps/resources/sidebars/` |
|
130
|
- Commerce modules: `sidebars/commerce-modules.mjs` or individual `sidebars/<module>.mjs` |
|
131
|
- How-to guides: `sidebars/how-to-tutorials.mjs` |
|
132
|
|
|
133
|
2. Add a link entry: |
|
134
|
```javascript |
|
135
|
{ |
|
136
|
type: "link", |
|
137
|
path: "/commerce-modules/<module>/<topic>", |
|
138
|
title: "Topic Title", |
|
139
|
} |
|
140
|
``` |
|
141
|
|
|
142
|
## Linking to Generated References |
|
143
|
|
|
144
|
Link to references by path but never create or edit reference files: |
|
145
|
|
|
146
|
```mdx |
|
147
|
[Product data model](/references/product/models/Product) |
|
148
|
[createProduct workflow](/references/core_flows/Product/functions/core_flows.Product.createProducts) |
|
149
|
``` |
|
150
|
|
|
151
|
Check what references exist by looking at the `www/apps/resources/references/` directory. |
|
152
|
|
|
153
|
## API Examples |
|
154
|
|
|
155
|
Use the JS SDK pattern for API call examples, not raw fetch: |
|
156
|
|
|
157
|
```ts |
|
158
|
import Medusa from "@medusajs/js-sdk" |
|
159
|
|
|
160
|
const sdk = new Medusa({ baseUrl: "http://localhost:9000" }) |
|
161
|
|
|
162
|
const { product } = await sdk.store.product.retrieve(productId) |
|
163
|
``` |
|
164
|
|
|
165
|
## When to update resources |
|
166
|
|
|
167
|
- A commerce module gains a new service method |
|
168
|
- A module's data model gets new fields |
|
169
|
- A new core-flows workflow or step is added |
|
170
|
- An existing workflow/step changes its input/output signature |
|
171
|
- A new how-to use case becomes possible due to a module change |
|
172
|
- Admin widget zones or UI route extension API changes (update relevant extension guides) |