@lukoweb/apitogo 0.2.54 → 0.2.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/cli/cli.js +2196 -1352
  2. package/dist/declarations/cli/platform/client/platform-api.d.ts +29 -0
  3. package/dist/declarations/cli/platform/helpers/platform-plan-catalog.d.ts +6 -0
  4. package/dist/declarations/config/validators/ZudokuConfig.d.ts +2 -0
  5. package/dist/declarations/lib/authentication/providers/openid.d.ts +2 -1
  6. package/dist/declarations/lib/plugins/markdown/index.d.ts +2 -1
  7. package/dist/flat-config.d.ts +1 -0
  8. package/docs/cli/commands.md +50 -32
  9. package/docs/cli/go-live.md +66 -93
  10. package/docs/cli/overview.md +18 -17
  11. package/docs/cli/setup.md +130 -141
  12. package/docs/cli/shape.md +94 -11
  13. package/docs/cli/walkthrough.md +1 -1
  14. package/docs/components/slot.mdx +116 -119
  15. package/docs/configuration/api-reference.md +98 -397
  16. package/docs/configuration/authentication.md +118 -159
  17. package/docs/configuration/footer.mdx +89 -118
  18. package/docs/configuration/make-config.mdx +2 -2
  19. package/docs/configuration/overview.md +97 -166
  20. package/docs/configuration/plans.md +100 -110
  21. package/docs/configuration/portal.md +116 -0
  22. package/docs/customization/colors-theme.mdx +255 -278
  23. package/docs/customization/fonts.md +105 -110
  24. package/docs/customization/landing-page.md +189 -188
  25. package/docs/deploy/apitogo.md +13 -17
  26. package/docs/deployment.md +15 -9
  27. package/docs/guides/stripe-setup.mdx +123 -0
  28. package/docs/markdown/frontmatter.md +172 -173
  29. package/docs/mcp/go-live.md +100 -100
  30. package/docs/mcp/overview.md +76 -76
  31. package/docs/quickstart.md +88 -72
  32. package/docs/writing.mdx +68 -72
  33. package/package.json +1 -1
  34. package/src/config/v2/docs-navigation.ts +7 -2
  35. package/src/config/v2/index.ts +1 -0
  36. package/src/config/v2/resolve.ts +28 -0
  37. package/src/config/v2/rules.ts +32 -1
  38. package/src/config/v2/schema.ts +9 -0
  39. package/src/config/v2/services.ts +90 -15
  40. package/src/config/v2/starter-landing.ts +41 -0
  41. package/src/config/v2/wrapper.ts +141 -7
  42. package/src/config/validators/ZudokuConfig.ts +794 -792
  43. package/src/lib/authentication/providers/openid.tsx +6 -1
  44. package/src/lib/plugins/markdown/index.tsx +86 -82
  45. package/src/vite/dev-server.ts +9 -1
  46. package/src/vite/dev-ssr-config.ts +32 -0
  47. package/src/vite/plugin-config.ts +4 -2
  48. package/src/vite/plugin-docs.ts +213 -205
  49. package/docs/concepts/auth-provider-api-identities.md +0 -105
  50. package/docs/configuration/ai-assistants.md +0 -65
  51. package/docs/configuration/api-catalog.md +0 -109
  52. package/docs/configuration/authentication-auth0.md +0 -181
  53. package/docs/configuration/authentication-azure-ad.md +0 -245
  54. package/docs/configuration/authentication-clerk.md +0 -117
  55. package/docs/configuration/authentication-firebase.md +0 -69
  56. package/docs/configuration/authentication-pingfederate.md +0 -143
  57. package/docs/configuration/authentication-supabase.md +0 -233
  58. package/docs/configuration/build-configuration.mdx +0 -147
  59. package/docs/configuration/docs.md +0 -282
  60. package/docs/configuration/llms.md +0 -90
  61. package/docs/configuration/manifest.md +0 -129
  62. package/docs/configuration/navigation.mdx +0 -415
  63. package/docs/configuration/protected-routes.md +0 -150
  64. package/docs/configuration/search.md +0 -164
  65. package/docs/configuration/sentry.mdx +0 -44
  66. package/docs/configuration/site.md +0 -124
  67. package/docs/configuration/slots.mdx +0 -125
  68. package/docs/configuration/vite-config.md +0 -18
  69. package/docs/custom-plugins.md +0 -285
  70. package/docs/deploy/apache-nginx.md +0 -41
  71. package/docs/deploy/cloudflare-pages.md +0 -74
  72. package/docs/deploy/direct-upload.md +0 -17
  73. package/docs/deploy/github-pages.md +0 -49
  74. package/docs/deploy/vercel.md +0 -101
  75. package/docs/extending/events.md +0 -124
  76. package/docs/guides/environment-variables.md +0 -94
  77. package/docs/guides/managing-api-keys-and-identities.md +0 -89
  78. package/docs/guides/navigation-rules.mdx +0 -203
  79. package/docs/guides/processors.mdx +0 -234
  80. package/docs/guides/transforming-examples.md +0 -156
  81. package/docs/guides/using-multiple-apis.md +0 -87
  82. package/docs/plugins.md +0 -24
package/docs/cli/setup.md CHANGED
@@ -1,141 +1,130 @@
1
- ---
2
- title: Install the CLI
3
- description:
4
- Install and invoke the APItoGo CLI to scaffold, configure, preview, and publish developer portals.
5
- sidebar_icon: terminal
6
- ---
7
-
8
- Use the **`apitogo`** CLI (`@lukoweb/apitogo`) to scaffold a local portal, shape
9
- `apitogo.config.json`, preview with `npx apitogo run`, and publish with `npx apitogo deploy`.
10
- Platform commands (`deploy`, `status`, `teardown`) use the same engine as MCP `publish_dev_portal`.
11
-
12
- Examples in these docs use **`npx apitogo`** so they run the project-local CLI. A global install is
13
- optional and not required.
14
-
15
- ## Prerequisites
16
-
17
- - **Node.js 20+**
18
- - Platform API credentials from [apitogo.com](https://apitogo.com) when you run `npx apitogo deploy`
19
- (API key id + secret)
20
-
21
- ## Install
22
-
23
- The CLI is the npm package **`@lukoweb/apitogo`**. It exposes the **`apitogo`** binary. Scaffold
24
- commands add it to your project and `npm install` puts it on `node_modules/.bin`. Invoke it with
25
- `npx apitogo`.
26
-
27
- ### New project (recommended)
28
-
29
- `npx @lukoweb/apitogo@latest init` creates a config version 2 project in the current folder. It
30
- shows what it will create and asks first (pass `--yes` to skip the question), writes
31
- `apitogo.config.json`, uses an existing `docs/` folder in place, and, in a new folder, creates
32
- `package.json` and installs `@lukoweb/apitogo`, `react` and `react-dom`:
33
-
34
- ```bash
35
- mkdir my-portal && cd my-portal
36
- npx @lukoweb/apitogo@latest init --name "Books API"
37
- npx apitogo run
38
- ```
39
-
40
- In an existing project the tool never edits your `package.json`. It prints the install command to
41
- run instead.
42
-
43
- The older scaffold (a `dev-portal` folder with secrets artifacts and automatic OpenAPI wiring) is
44
- still available with `--no-v2`:
45
-
46
- ```bash
47
- npx @lukoweb/apitogo@latest init --no-v2
48
- cd dev-portal
49
- npx apitogo run
50
- ```
51
-
52
- Named folder or site name:
53
-
54
- ```bash
55
- npx @lukoweb/apitogo@latest init ./my-portal --name "Books API"
56
- cd ./my-portal
57
- npx apitogo run
58
- ```
59
-
60
- #### Scaffold options
61
-
62
- | Flag | Effect |
63
- | ------------------------- | ------------------------------------------------------------------------ |
64
- | `[dir]` | Target folder (default: the current folder; `dev-portal` with `--no-v2`) |
65
- | `--name <string>` | Site / package name (also used when `dir` is `.`) |
66
- | `--no-install` | Skip `npm install` after scaffold |
67
- | `--no-v2` | Use the older `dev-portal` scaffold instead of config version 2 |
68
- | `--yes` | Do not ask for confirmation (config version 2) |
69
- | `--overwrite` | Replace an existing non-empty target directory |
70
- | `--json` | Print a JSON result payload on stdout |
71
- | `--openapi-search <mode>` | Auto-discover OpenAPI: `nearby` (default), `site`, or `none` |
72
-
73
- `npx @lukoweb/apitogo init` is local only — it does not call the platform. After `config`, run
74
- `npx apitogo run` to preview, then `npx apitogo deploy` when ready to go live.
75
-
76
- ### How to run `apitogo`
77
-
78
- | Situation | Command |
79
- | --------------------------------------------------------- | --------------------------------------------------- |
80
- | After `init` or `npm install` in the project | `npx apitogo <command>` (e.g. `npx apitogo config`) |
81
- | One-off, no project yet | `npx @lukoweb/apitogo <command>` |
82
- | After [optional global install](#optional-global-install) | `apitogo <command>` anywhere |
83
-
84
- `npm run dev` / `npm run build` use the project-local CLI via `package.json` scripts — no global
85
- install required.
86
-
87
- ### Optional global install
88
-
89
- ```bash
90
- npm install -g @lukoweb/apitogo
91
- ```
92
-
93
- Then run `apitogo` from any directory:
94
-
95
- ```bash
96
- apitogo --help
97
- ```
98
-
99
- Upgrade later with `npm install -g @lukoweb/apitogo@latest`. Uninstall with
100
- `npm uninstall -g @lukoweb/apitogo`. Prefer `npx apitogo` in projects so each site uses the version
101
- in its `package.json`.
102
-
103
- ## Platform credentials
104
-
105
- Export these before `npx apitogo deploy`, `npx apitogo status`, or `npx apitogo teardown`:
106
-
107
- | Variable | Required | Purpose |
108
- | -------------------- | -------- | ----------------- |
109
- | `APITOGO_API_KEY_ID` | Yes | Platform API auth |
110
- | `APITOGO_API_SECRET` | Yes | Platform API auth |
111
-
112
- Optional:
113
-
114
- | Variable | Purpose |
115
- | ------------------ | ---------------------------------------------------------- |
116
- | `APITOGO_API_URL` | Override platform API base URL |
117
- | `APITOGO_CLI_PATH` | Local `@lukoweb/apitogo` / doc-tool checkout for MCP spawn |
118
-
119
- Never commit secrets. Site auth secrets (OIDC, Stripe) belong in the portal **`.env`** as
120
- `APITOGO_CONFIG_AUTHENTICATION__*` — see [Go live](./go-live.md).
121
-
122
- ## Verify
123
-
124
- ```bash
125
- npx apitogo --help
126
- ```
127
-
128
- You should see `init`, `config`, `run`, `build`, `deploy`, `status`, and `teardown`.
129
-
130
- With credentials set:
131
-
132
- ```bash
133
- npx apitogo status
134
- ```
135
-
136
- ## Next
137
-
138
- - [CLI overview](./overview.md)
139
- - [Shape](./shape.md) — scaffold and local preview
140
- - [Go live](./go-live.md) — `npx apitogo deploy`
141
- - [Commands](./commands.md) — full catalog
1
+ ---
2
+ title: Install the CLI
3
+ description:
4
+ Install and invoke the APItoGo CLI to scaffold, configure, preview, and publish developer portals.
5
+ sidebar_icon: terminal
6
+ ---
7
+
8
+ Use the **`apitogo`** CLI (`@lukoweb/apitogo`) to scaffold a local portal, shape
9
+ `apitogo.config.json`, preview with `npx apitogo run`, and publish with `npx apitogo deploy`.
10
+ Platform commands (`deploy`, `status`, `teardown`) use the same engine as MCP `publish_dev_portal`.
11
+
12
+ Examples in these docs use **`npx apitogo`** so they run the project-local CLI. A global install is
13
+ optional and not required.
14
+
15
+ ## Prerequisites
16
+
17
+ - **Node.js 20+**
18
+ - Platform API credentials from [apitogo.com](https://apitogo.com) when you run `npx apitogo deploy`
19
+ (API key id + secret)
20
+
21
+ ## Install
22
+
23
+ The CLI is the npm package **`@lukoweb/apitogo`**. It exposes the **`apitogo`** binary. Scaffold
24
+ commands add it to your project and `npm install` puts it on `node_modules/.bin`. Invoke it with
25
+ `npx apitogo`.
26
+
27
+ ### New project (recommended)
28
+
29
+ `npx @lukoweb/apitogo@latest init` creates a config version 2 project in the current folder. It
30
+ shows what it will create and asks first (pass `--yes` to skip the question), writes
31
+ `apitogo.config.json`, uses an existing `docs/` folder in place, and, in a new folder, creates
32
+ `package.json` and installs `@lukoweb/apitogo`, `react` and `react-dom`:
33
+
34
+ ```bash
35
+ mkdir my-portal && cd my-portal
36
+ npx @lukoweb/apitogo@latest init --name "Books API"
37
+ npx apitogo run
38
+ ```
39
+
40
+ In an existing project the tool never edits your `package.json`. It prints the install command to
41
+ run instead.
42
+
43
+ Named folder or site name:
44
+
45
+ ```bash
46
+ npx @lukoweb/apitogo@latest init ./my-portal --name "Books API"
47
+ cd ./my-portal
48
+ npx apitogo run
49
+ ```
50
+
51
+ #### Scaffold options
52
+
53
+ | Flag | Effect |
54
+ | ----------------- | --------------------------------------------- |
55
+ | `[dir]` | Target folder (default: the current folder) |
56
+ | `--name <string>` | Project name (default: the folder's name) |
57
+ | `--yes` | Do not ask for confirmation |
58
+ | `--dry-run` | Show what would be created, and write nothing |
59
+ | `--force` | Replace an existing `apitogo.config.json` |
60
+ | `--json` | Print a JSON result payload on stdout |
61
+
62
+ `npx @lukoweb/apitogo init` is local only — it does not call the platform. After `config`, run
63
+ `npx apitogo run` to preview, then `npx apitogo deploy` when ready to go live.
64
+
65
+ ### How to run `apitogo`
66
+
67
+ | Situation | Command |
68
+ | --------------------------------------------------------- | --------------------------------------------------- |
69
+ | After `init` or `npm install` in the project | `npx apitogo <command>` (e.g. `npx apitogo config`) |
70
+ | One-off, no project yet | `npx @lukoweb/apitogo <command>` |
71
+ | After [optional global install](#optional-global-install) | `apitogo <command>` anywhere |
72
+
73
+ `npm run dev` / `npm run build` use the project-local CLI via `package.json` scripts — no global
74
+ install required.
75
+
76
+ ### Optional global install
77
+
78
+ ```bash
79
+ npm install -g @lukoweb/apitogo
80
+ ```
81
+
82
+ Then run `apitogo` from any directory:
83
+
84
+ ```bash
85
+ apitogo --help
86
+ ```
87
+
88
+ Upgrade later with `npm install -g @lukoweb/apitogo@latest`. Uninstall with
89
+ `npm uninstall -g @lukoweb/apitogo`. Prefer `npx apitogo` in projects so each site uses the version
90
+ in its `package.json`.
91
+
92
+ ## Platform credentials
93
+
94
+ Export these before `npx apitogo deploy`, `npx apitogo status`, or `npx apitogo teardown`:
95
+
96
+ | Variable | Required | Purpose |
97
+ | -------------------- | -------- | ----------------- |
98
+ | `APITOGO_API_KEY_ID` | Yes | Platform API auth |
99
+ | `APITOGO_API_SECRET` | Yes | Platform API auth |
100
+
101
+ Optional:
102
+
103
+ | Variable | Purpose |
104
+ | ------------------ | ---------------------------------------------------------- |
105
+ | `APITOGO_API_URL` | Override platform API base URL |
106
+ | `APITOGO_CLI_PATH` | Local `@lukoweb/apitogo` / doc-tool checkout for MCP spawn |
107
+
108
+ Never commit secrets. Secrets such as the Stripe key are project secrets: deploy asks for them, and
109
+ `npx apitogo secrets set <NAME>` changes them. See [Go live](./go-live.md).
110
+
111
+ ## Verify
112
+
113
+ ```bash
114
+ npx apitogo --help
115
+ ```
116
+
117
+ You should see `init`, `config`, `run`, `build`, `deploy`, `status`, and `teardown`.
118
+
119
+ With credentials set:
120
+
121
+ ```bash
122
+ npx apitogo status
123
+ ```
124
+
125
+ ## Next
126
+
127
+ - [CLI overview](./overview.md)
128
+ - [Shape](./shape.md) — scaffold and local preview
129
+ - [Go live](./go-live.md) — `npx apitogo deploy`
130
+ - [Commands](./commands.md) — full catalog
package/docs/cli/shape.md CHANGED
@@ -13,13 +13,12 @@ Requires the **`apitogo`** CLI (`@lukoweb/apitogo`). If you have not installed i
13
13
 
14
14
  ## Happy path
15
15
 
16
- `npx @lukoweb/apitogo@latest init` scaffolds into `./dev-portal` by default (pass a folder name or
17
- `--name` to override), installs dependencies, and wires nearby OpenAPI / docs. Then run config via
18
- `npx`:
16
+ `npx @lukoweb/apitogo@latest init` creates a project in the current folder: it writes
17
+ `apitogo.config.json`, uses an existing `docs/` folder, and installs the CLI. Then shape it with
18
+ `npx apitogo config`:
19
19
 
20
20
  ```bash
21
21
  npx @lukoweb/apitogo@latest init
22
- cd dev-portal
23
22
  npx apitogo config # backend, OpenAPI, pages, plans (apply each immediately)
24
23
  npx apitogo run # http://localhost:3000
25
24
  ```
@@ -52,8 +51,9 @@ Fonts and colors are **not** prompted. See [Colors & theme](../customization/col
52
51
 
53
52
  **Paid plans:** payments go through Stripe. Once a plan has a price, `npx apitogo deploy` asks for
54
53
  your Stripe secret key (if the project has none yet) and stores it as a project secret. Free and
55
- contact-us plans need no key. Paid plans also need **Starter** or **Professional** platform hosting;
56
- **Free** cannot publish paid gateway plans or custom domains.
54
+ contact-us plans need no key. [Set up Stripe for paid plans](../guides/stripe-setup.mdx) shows where
55
+ to find the key and how to add the webhook, with pictures. Paid plans also need **Starter** or
56
+ **Professional** platform hosting; **Free** cannot publish paid gateway plans or custom domains.
57
57
 
58
58
  Full reference: [Make config (CLI)](../configuration/make-config.mdx) ·
59
59
  [Gateway plans](../configuration/plans.md)
@@ -88,12 +88,95 @@ After `npx apitogo config`, edit the manifest and site files directly:
88
88
 
89
89
  - **Services, backend, OpenAPI files** — `apitogo.config.json`
90
90
  - **Plans** — `apitogo/plans.json`
91
- - **Docs pages** — `apitogo/portal/pages/**/*.{md,mdx,tsx}` (`.tsx` files are React pages)
91
+ - **Docs pages** — the files `portal.docs.content` names, by default
92
+ `apitogo/portal/pages/**/*.{md,mdx,tsx}` (`.tsx` files are React pages)
92
93
  - **Home page** — the file in `portal.landing` (for example
93
94
  `apitogo/portal/landing/LandingPage.tsx`)
95
+ - **Footer** — the file in `portal.footer` (for example `apitogo/portal/footer/Footer.tsx`). It is
96
+ shown under every page except the console's (`/account`, `/login`, `/signup`). Remove
97
+ `portal.footer` to have none.
98
+ - **Colors** — `apitogo/portal/theme.json` (or the file in `portal.theme`). See
99
+ [Colors & theme](../customization/colors-theme.mdx).
100
+ - **Logo** — `portal.logo`, an image in `apitogo/portal/public/` or an `https://` address
101
+
102
+ ```json title=apitogo.config.json
103
+ {
104
+ "portal": {
105
+ "landing": "apitogo/portal/landing/LandingPage.tsx",
106
+ "footer": "apitogo/portal/footer/Footer.tsx",
107
+ "logo": {
108
+ "light": "apitogo/portal/public/logo.svg",
109
+ "dark": "apitogo/portal/public/logo-dark.svg"
110
+ },
111
+ "docs": { "content": ["apitogo/portal/pages/**/*.{md,mdx}"] }
112
+ }
113
+ }
114
+ ```
115
+
116
+ `"logo": "apitogo/portal/public/logo.svg"` uses one image for both color schemes. Without a logo the
117
+ header shows `portal.name`.
118
+
119
+ ### Order of the docs pages
120
+
121
+ The sidebar lists a folder's `index` page first, then pages with an `order`, lowest first, then the
122
+ rest (introduction, getting started and overview before the others, then by name). Set the order in
123
+ the page itself:
124
+
125
+ ```md title=apitogo/portal/pages/authentication.md
126
+ ---
127
+ title: Authentication
128
+ order: 2
129
+ ---
130
+ ```
131
+
132
+ In a React page: `export const order = 2;`.
133
+
134
+ When the portal has a home page, `/` shows it, and an `index` page of the docs stays at `/index`.
135
+
136
+ ### What the pricing cards show
137
+
138
+ Each card in `apitogo/plans.json` lists, in this order:
139
+
140
+ 1. The plan's limits: the rate limit (`limits.rateLimit`) and the quota (`limits.quota`)
141
+ 2. Its own lines, from `features`
142
+ 3. The endpoints the plan includes: the ones in `includedActions`, or every operation of the gateway
143
+ when the plan names none
144
+
145
+ ```json title=apitogo/plans.json
146
+ {
147
+ "version": 1,
148
+ "plans": [
149
+ {
150
+ "sku": "pro",
151
+ "displayName": "Pro",
152
+ "priceAmount": 19,
153
+ "priceCurrency": "usd",
154
+ "billingInterval": "month",
155
+ "limits": { "rateLimit": { "calls": 600, "periodSeconds": 60 } },
156
+ "features": ["Email support", "Usage history"],
157
+ "includedActions": ["get:/api/makes", "get:/api/makes/{makeId}"]
158
+ }
159
+ ]
160
+ }
161
+ ```
162
+
163
+ `npx apitogo run` shows the same cards as the deployed portal.
164
+
165
+ ## Add a portal from scratch
166
+
167
+ In a project that has no portal yet:
168
+
169
+ ```bash
170
+ npx apitogo add portal
171
+ ```
172
+
173
+ It adds `portal` to `apitogo.config.json` and writes the files above: `introduction.mdx` (the
174
+ starter template adds a home page; `blank` writes an empty `pages/` folder), `theme.json` and the
175
+ footer. Docs you already have (a `docs/` folder, for example) are used instead of a first page; pass
176
+ `--docs <path>` to name them. Files that exist are never overwritten.
94
177
 
95
- Never put OIDC or Stripe secrets in `apitogo.config.json`. Use `.env` with
96
- `APITOGO_CONFIG_AUTHENTICATION__*` before publish.
178
+ Never put secrets in `apitogo.config.json`: the config names a project secret (`secret:NAME`), and
179
+ `npx apitogo secrets set NAME` stores the value.
97
180
 
98
181
  ## Preview locally
99
182
 
@@ -113,11 +196,11 @@ Shape-phase edits hot-reload when the dev server is running.
113
196
 
114
197
  ## Existing docs + OpenAPI folder
115
198
 
116
- If you already have `pages/` and an OpenAPI spec:
199
+ In a folder that already has docs and an OpenAPI file, run `init` there: it uses the `docs/` folder
200
+ in place, and `npx apitogo config` (openapi) adds the OpenAPI file:
117
201
 
118
202
  ```bash
119
203
  npx @lukoweb/apitogo@latest init
120
- cd dev-portal
121
204
  npx apitogo config
122
205
  npx apitogo run
123
206
  ```
@@ -49,7 +49,7 @@ npx apitogo add plans --template free
49
49
  `--create-spec` writes a small OpenAPI file with one `GET /health` operation, so the gateway has
50
50
  something to expose. For a real API, point `gateway.specs` at your own OpenAPI file instead.
51
51
 
52
- The Free template in `plans.json` allows 3 calls per minute and 1000 calls per 30 days. Change the
52
+ The Free template in `plans.json` allows 60 calls per minute and 1000 calls per 30 days. Change the
53
53
  numbers in `plans.json` and deploy again to change the limits.
54
54
 
55
55
  With plans in the project, customers call the gateway with their API key alone. Their login token is
@@ -1,119 +1,116 @@
1
- ---
2
- title: Slot
3
- sidebar_icon: between-horizontal-start
4
- description:
5
- Use the low-level Slot component for advanced slot management in custom pages and MDX content.
6
- ---
7
-
8
- The `Slot` component provides low-level access to APIToGo's slot system, allowing you to
9
- programmatically manage content injection in custom pages and React components.
10
-
11
- ## Import
12
-
13
- ```tsx
14
- import { Slot } from "@lukoweb/apitogo/components";
15
- ```
16
-
17
- ## Components
18
-
19
- The Slot system consists of two main components:
20
-
21
- ### Slot.Target
22
-
23
- Renders content that has been injected into a specific slot.
24
-
25
- ```tsx
26
- <Slot.Target name="my-slot" fallback={<div>No content</div>} />
27
- ```
28
-
29
- **Props:**
30
-
31
- - `name` (required): The slot name to render content for
32
- - `fallback` (optional): Content to show when no slot content is available
33
-
34
- ### Slot.Source
35
-
36
- Injects content into a specific slot. This component renders nothing but registers content to be
37
- displayed by `Slot.Target` components.
38
-
39
- ```tsx
40
- <Slot.Source name="my-slot" type="append">
41
- <div>Content to inject</div>
42
- </Slot.Source>
43
- ```
44
-
45
- **Props:**
46
-
47
- - `name` (required): The slot name to inject content into
48
- - `type` (optional): How to handle multiple content sources
49
- - `"replace"` (default): Replace existing content
50
- - `"prepend"`: Add before existing content
51
- - `"append"`: Add after existing content
52
- - `children`: The content to inject
53
-
54
- ## Usage Example
55
-
56
- ```tsx
57
- function MyCustomPage() {
58
- return (
59
- <div>
60
- <h1>My Page</h1>
61
-
62
- {/* Render slot content here */}
63
- <Slot.Target name="custom-page-header" />
64
-
65
- {/* Inject content into a slot */}
66
- <Slot.Source name="custom-page-header">
67
- <div className="bg-blue-100 p-4 rounded">Custom header content</div>
68
- </Slot.Source>
69
-
70
- <p>Page content here...</p>
71
- </div>
72
- );
73
- }
74
- ```
75
-
76
- ## Type Safety
77
-
78
- The Slot component is fully type-safe. All predefined slot names are available with autocomplete:
79
-
80
- ```tsx
81
- // These will show autocomplete for available slot names
82
- <Slot.Target name="head-navigation-end" />
83
- <Slot.Source name="footer-before">Content</Slot.Source>
84
- ```
85
-
86
- ### Adding Custom Slot Names
87
-
88
- To add your own slot names with full type safety, augment the `CustomSlotNames` type:
89
-
90
- ```tsx
91
- // types/slots.d.ts
92
- declare module "@lukoweb/apitogo" {
93
- type CustomSlotNames = "my-custom-header" | "sidebar-extra";
94
- }
95
- ```
96
-
97
- ## Integration with Configuration
98
-
99
- The Slot component works with configuration-based slots. Content defined in your
100
- `apitogo.config.json` and content injected via `Slot.Source` components will be combined according
101
- to the `type` parameter.
102
-
103
- ```tsx
104
- // In your site config
105
- slots: {
106
- "page-header": <div>Config header</div>
107
- }
108
-
109
- // In your component
110
- <Slot.Source name="page-header" type="append">
111
- <Button>Go Home</Button>
112
- </Slot.Source>
113
-
114
- // Renders both: Config header, then Component button
115
- <Slot.Target name="page-header" />
116
- ```
117
-
118
- For basic configuration usage, see the [Slots Configuration](/docs/configuration/slots)
119
- documentation.
1
+ ---
2
+ title: Slot
3
+ sidebar_icon: between-horizontal-start
4
+ description:
5
+ Use the low-level Slot component for advanced slot management in custom pages and MDX content.
6
+ ---
7
+
8
+ The `Slot` component provides low-level access to APIToGo's slot system, allowing you to
9
+ programmatically manage content injection in custom pages and React components.
10
+
11
+ ## Import
12
+
13
+ ```tsx
14
+ import { Slot } from "@lukoweb/apitogo/components";
15
+ ```
16
+
17
+ ## Components
18
+
19
+ The Slot system consists of two main components:
20
+
21
+ ### Slot.Target
22
+
23
+ Renders content that has been injected into a specific slot.
24
+
25
+ ```tsx
26
+ <Slot.Target name="my-slot" fallback={<div>No content</div>} />
27
+ ```
28
+
29
+ **Props:**
30
+
31
+ - `name` (required): The slot name to render content for
32
+ - `fallback` (optional): Content to show when no slot content is available
33
+
34
+ ### Slot.Source
35
+
36
+ Injects content into a specific slot. This component renders nothing but registers content to be
37
+ displayed by `Slot.Target` components.
38
+
39
+ ```tsx
40
+ <Slot.Source name="my-slot" type="append">
41
+ <div>Content to inject</div>
42
+ </Slot.Source>
43
+ ```
44
+
45
+ **Props:**
46
+
47
+ - `name` (required): The slot name to inject content into
48
+ - `type` (optional): How to handle multiple content sources
49
+ - `"replace"` (default): Replace existing content
50
+ - `"prepend"`: Add before existing content
51
+ - `"append"`: Add after existing content
52
+ - `children`: The content to inject
53
+
54
+ ## Usage Example
55
+
56
+ ```tsx
57
+ function MyCustomPage() {
58
+ return (
59
+ <div>
60
+ <h1>My Page</h1>
61
+
62
+ {/* Render slot content here */}
63
+ <Slot.Target name="custom-page-header" />
64
+
65
+ {/* Inject content into a slot */}
66
+ <Slot.Source name="custom-page-header">
67
+ <div className="bg-blue-100 p-4 rounded">Custom header content</div>
68
+ </Slot.Source>
69
+
70
+ <p>Page content here...</p>
71
+ </div>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ## Type Safety
77
+
78
+ The Slot component is fully type-safe. All predefined slot names are available with autocomplete:
79
+
80
+ ```tsx
81
+ // These will show autocomplete for available slot names
82
+ <Slot.Target name="head-navigation-end" />
83
+ <Slot.Source name="footer-before">Content</Slot.Source>
84
+ ```
85
+
86
+ ### Adding Custom Slot Names
87
+
88
+ To add your own slot names with full type safety, augment the `CustomSlotNames` type:
89
+
90
+ ```tsx
91
+ // types/slots.d.ts
92
+ declare module "@lukoweb/apitogo" {
93
+ type CustomSlotNames = "my-custom-header" | "sidebar-extra";
94
+ }
95
+ ```
96
+
97
+ ## Integration with Configuration
98
+
99
+ The Slot component works with configuration-based slots. Content defined in your
100
+ `apitogo.config.json` and content injected via `Slot.Source` components will be combined according
101
+ to the `type` parameter.
102
+
103
+ ```tsx
104
+ // In your site config
105
+ slots: {
106
+ "page-header": <div>Config header</div>
107
+ }
108
+
109
+ // In your component
110
+ <Slot.Source name="page-header" type="append">
111
+ <Button>Go Home</Button>
112
+ </Slot.Source>
113
+
114
+ // Renders both: Config header, then Component button
115
+ <Slot.Target name="page-header" />
116
+ ```