@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.
- package/dist/cli/cli.js +2196 -1352
- package/dist/declarations/cli/platform/client/platform-api.d.ts +29 -0
- package/dist/declarations/cli/platform/helpers/platform-plan-catalog.d.ts +6 -0
- package/dist/declarations/config/validators/ZudokuConfig.d.ts +2 -0
- package/dist/declarations/lib/authentication/providers/openid.d.ts +2 -1
- package/dist/declarations/lib/plugins/markdown/index.d.ts +2 -1
- package/dist/flat-config.d.ts +1 -0
- package/docs/cli/commands.md +50 -32
- package/docs/cli/go-live.md +66 -93
- package/docs/cli/overview.md +18 -17
- package/docs/cli/setup.md +130 -141
- package/docs/cli/shape.md +94 -11
- package/docs/cli/walkthrough.md +1 -1
- package/docs/components/slot.mdx +116 -119
- package/docs/configuration/api-reference.md +98 -397
- package/docs/configuration/authentication.md +118 -159
- package/docs/configuration/footer.mdx +89 -118
- package/docs/configuration/make-config.mdx +2 -2
- package/docs/configuration/overview.md +97 -166
- package/docs/configuration/plans.md +100 -110
- package/docs/configuration/portal.md +116 -0
- package/docs/customization/colors-theme.mdx +255 -278
- package/docs/customization/fonts.md +105 -110
- package/docs/customization/landing-page.md +189 -188
- package/docs/deploy/apitogo.md +13 -17
- package/docs/deployment.md +15 -9
- package/docs/guides/stripe-setup.mdx +123 -0
- package/docs/markdown/frontmatter.md +172 -173
- package/docs/mcp/go-live.md +100 -100
- package/docs/mcp/overview.md +76 -76
- package/docs/quickstart.md +88 -72
- package/docs/writing.mdx +68 -72
- package/package.json +1 -1
- package/src/config/v2/docs-navigation.ts +7 -2
- package/src/config/v2/index.ts +1 -0
- package/src/config/v2/resolve.ts +28 -0
- package/src/config/v2/rules.ts +32 -1
- package/src/config/v2/schema.ts +9 -0
- package/src/config/v2/services.ts +90 -15
- package/src/config/v2/starter-landing.ts +41 -0
- package/src/config/v2/wrapper.ts +141 -7
- package/src/config/validators/ZudokuConfig.ts +794 -792
- package/src/lib/authentication/providers/openid.tsx +6 -1
- package/src/lib/plugins/markdown/index.tsx +86 -82
- package/src/vite/dev-server.ts +9 -1
- package/src/vite/dev-ssr-config.ts +32 -0
- package/src/vite/plugin-config.ts +4 -2
- package/src/vite/plugin-docs.ts +213 -205
- package/docs/concepts/auth-provider-api-identities.md +0 -105
- package/docs/configuration/ai-assistants.md +0 -65
- package/docs/configuration/api-catalog.md +0 -109
- package/docs/configuration/authentication-auth0.md +0 -181
- package/docs/configuration/authentication-azure-ad.md +0 -245
- package/docs/configuration/authentication-clerk.md +0 -117
- package/docs/configuration/authentication-firebase.md +0 -69
- package/docs/configuration/authentication-pingfederate.md +0 -143
- package/docs/configuration/authentication-supabase.md +0 -233
- package/docs/configuration/build-configuration.mdx +0 -147
- package/docs/configuration/docs.md +0 -282
- package/docs/configuration/llms.md +0 -90
- package/docs/configuration/manifest.md +0 -129
- package/docs/configuration/navigation.mdx +0 -415
- package/docs/configuration/protected-routes.md +0 -150
- package/docs/configuration/search.md +0 -164
- package/docs/configuration/sentry.mdx +0 -44
- package/docs/configuration/site.md +0 -124
- package/docs/configuration/slots.mdx +0 -125
- package/docs/configuration/vite-config.md +0 -18
- package/docs/custom-plugins.md +0 -285
- package/docs/deploy/apache-nginx.md +0 -41
- package/docs/deploy/cloudflare-pages.md +0 -74
- package/docs/deploy/direct-upload.md +0 -17
- package/docs/deploy/github-pages.md +0 -49
- package/docs/deploy/vercel.md +0 -101
- package/docs/extending/events.md +0 -124
- package/docs/guides/environment-variables.md +0 -94
- package/docs/guides/managing-api-keys-and-identities.md +0 -89
- package/docs/guides/navigation-rules.mdx +0 -203
- package/docs/guides/processors.mdx +0 -234
- package/docs/guides/transforming-examples.md +0 -156
- package/docs/guides/using-multiple-apis.md +0 -87
- package/docs/plugins.md +0 -24
package/docs/custom-plugins.md
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Custom Plugins
|
|
3
|
-
sidebar_icon: list-end
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
APIToGo is highly extensible. You can create custom plugins to add new functionality to your
|
|
7
|
-
documentation site. This guide will show you how to create and use plugins in your APIToGo
|
|
8
|
-
configuration.
|
|
9
|
-
|
|
10
|
-
## Plugin Types
|
|
11
|
-
|
|
12
|
-
All plugins in APIToGo must implement the `ApitogoPlugin` type, which is a union of these plugin
|
|
13
|
-
interfaces:
|
|
14
|
-
|
|
15
|
-
- **CommonPlugin**: Basic plugin with initialization, head elements, and MDX component customization
|
|
16
|
-
- **ProfileMenuPlugin**: Add custom items to the profile menu
|
|
17
|
-
- **NavigationPlugin**: Define custom routes and sidebar items
|
|
18
|
-
- **ApiIdentityPlugin**: Provide API identities for testing
|
|
19
|
-
- **SearchProviderPlugin**: Implement custom search functionality
|
|
20
|
-
- **EventConsumerPlugin**: Handle custom events
|
|
21
|
-
- **TransformConfigPlugin**: Modify configuration at build-time
|
|
22
|
-
|
|
23
|
-
## Defining Plugins
|
|
24
|
-
|
|
25
|
-
You can define plugins in your APIToGo configuration using objects with explicit type declarations:
|
|
26
|
-
|
|
27
|
-
### Common Plugin Example
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import type { ApitogoPlugin } from "@lukoweb/apitogo";
|
|
31
|
-
|
|
32
|
-
const commonPlugin: ApitogoPlugin = {
|
|
33
|
-
initialize: async (context) => {
|
|
34
|
-
// Initialization logic
|
|
35
|
-
},
|
|
36
|
-
getHead: () => <link rel="stylesheet" href="/custom-styles.css" />,
|
|
37
|
-
getMdxComponents: () => ({
|
|
38
|
-
// Custom MDX components
|
|
39
|
-
}),
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const config: ApitogoConfig = {
|
|
43
|
-
// ... other config
|
|
44
|
-
plugins: [commonPlugin],
|
|
45
|
-
};
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### API Identity Plugin Example
|
|
49
|
-
|
|
50
|
-
```tsx
|
|
51
|
-
import type { ApitogoPlugin, ApiIdentity } from "@lukoweb/apitogo";
|
|
52
|
-
|
|
53
|
-
const apiIdentityPlugin: ApitogoPlugin = {
|
|
54
|
-
getIdentities: async (context) => {
|
|
55
|
-
return [
|
|
56
|
-
{
|
|
57
|
-
label: "Test User",
|
|
58
|
-
id: "test-user",
|
|
59
|
-
authorizeRequest: (request: Request) => {
|
|
60
|
-
request.headers.set("Authorization", "Bearer test-token");
|
|
61
|
-
return request;
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
] as ApiIdentity[];
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// In your site config
|
|
69
|
-
const config: ApitogoConfig = {
|
|
70
|
-
// ... other config
|
|
71
|
-
plugins: [apiIdentityPlugin],
|
|
72
|
-
};
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Example Implementations
|
|
76
|
-
|
|
77
|
-
Here are some common plugin implementations:
|
|
78
|
-
|
|
79
|
-
### Google Tag Manager
|
|
80
|
-
|
|
81
|
-
Below is a sample of adding the necessary scripts for GTM, but this could apply to any tag manager
|
|
82
|
-
or tracking script.
|
|
83
|
-
|
|
84
|
-
```tsx
|
|
85
|
-
import type { ApitogoPlugin } from "@lukoweb/apitogo";
|
|
86
|
-
|
|
87
|
-
const commonPlugin: ApitogoPlugin = {
|
|
88
|
-
getHead: () => {
|
|
89
|
-
return (
|
|
90
|
-
<script>
|
|
91
|
-
{`
|
|
92
|
-
(function (w, d, s, l, i) {
|
|
93
|
-
w[l] = w[l] || [];
|
|
94
|
-
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
|
|
95
|
-
var f = d.getElementsByTagName(s)[0],
|
|
96
|
-
j = d.createElement(s),
|
|
97
|
-
dl = l != "dataLayer" ? "&l=" + l : "";
|
|
98
|
-
j.async = true;
|
|
99
|
-
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
|
|
100
|
-
f.parentNode.insertBefore(j, f);
|
|
101
|
-
})(window, document, "script", "dataLayer", "GTM-<YOUR GTM ID HERE>");`}
|
|
102
|
-
</script>
|
|
103
|
-
);
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
#### Tracking `page_view` Events
|
|
109
|
-
|
|
110
|
-
APIToGo is a single page application so typical `page_view` events are not captured by most
|
|
111
|
-
analytics scripts or tag managers. Instead, you must listen to the `location`
|
|
112
|
-
[event](./extending/events.md) with a plugin and log navigation changes in code.
|
|
113
|
-
|
|
114
|
-
```tsx
|
|
115
|
-
import type { ApitogoPlugin } from "@lukoweb/apitogo";
|
|
116
|
-
|
|
117
|
-
const navigationLoggerPlugin: ApitogoPlugin = {
|
|
118
|
-
events: {
|
|
119
|
-
location: ({ from, to }) => {
|
|
120
|
-
if (!from) return;
|
|
121
|
-
window.dataLayer.push({
|
|
122
|
-
event: "page_view",
|
|
123
|
-
page_path: to.pathname,
|
|
124
|
-
page_title: document.title,
|
|
125
|
-
page_location: window.location.href,
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
If you are using TypeScript, you will also need to add the following type declaration to the file
|
|
133
|
-
this plugin is declared
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
declare global {
|
|
137
|
-
interface Window {
|
|
138
|
-
dataLayer: Record<string, any>[];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Navigation Plugin
|
|
144
|
-
|
|
145
|
-
```tsx
|
|
146
|
-
import type { ApitogoPlugin, RouteObject } from "@lukoweb/apitogo";
|
|
147
|
-
|
|
148
|
-
const navigationPlugin: ApitogoPlugin = {
|
|
149
|
-
getRoutes: (): RouteObject[] => {
|
|
150
|
-
return [
|
|
151
|
-
{
|
|
152
|
-
path: "/custom",
|
|
153
|
-
element: <CustomPage />,
|
|
154
|
-
},
|
|
155
|
-
];
|
|
156
|
-
},
|
|
157
|
-
getSidebar: async (path: string) => {
|
|
158
|
-
// Return custom sidebar items
|
|
159
|
-
return {
|
|
160
|
-
items: [{ id: "custom", label: "Custom Page" }],
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Wrapping Routes with Context or Layout
|
|
167
|
-
|
|
168
|
-
You can wrap your plugin's routes with a context provider or custom layout using React Router's
|
|
169
|
-
nested route pattern. The parent route renders an `<Outlet />` where child routes will appear.
|
|
170
|
-
|
|
171
|
-
```tsx
|
|
172
|
-
import { createContext, useContext } from "react";
|
|
173
|
-
import type { ApitogoPlugin, RouteObject } from "@lukoweb/apitogo";
|
|
174
|
-
import { Outlet } from "@lukoweb/apitogo/router";
|
|
175
|
-
|
|
176
|
-
const MyContext = createContext("value");
|
|
177
|
-
|
|
178
|
-
const pluginWithContext: ApitogoPlugin = {
|
|
179
|
-
getRoutes: () => [
|
|
180
|
-
{
|
|
181
|
-
element: (
|
|
182
|
-
<MyContext.Provider value="hello">
|
|
183
|
-
<Outlet />
|
|
184
|
-
</MyContext.Provider>
|
|
185
|
-
),
|
|
186
|
-
children: [
|
|
187
|
-
{ path: "/custom", element: <CustomPage /> },
|
|
188
|
-
{ path: "/custom/nested", element: <NestedPage /> },
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
};
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
All child routes will have access to `MyContext`. This pattern works for any wrapper including
|
|
196
|
-
layouts, error boundaries, or data providers.
|
|
197
|
-
|
|
198
|
-
### Dropdown Navigation Plugin
|
|
199
|
-
|
|
200
|
-
```tsx
|
|
201
|
-
import type { ApitogoPlugin, RouteObject } from "@lukoweb/apitogo";
|
|
202
|
-
import { UserIcon } from "@lukoweb/apitogo/icons";
|
|
203
|
-
|
|
204
|
-
const AccountPageNavItemPlugin: ApitogoPlugin = {
|
|
205
|
-
getRoutes: (): RouteObject[] => {
|
|
206
|
-
return [
|
|
207
|
-
{
|
|
208
|
-
path: "/account",
|
|
209
|
-
element: <Account />, // This is a custom page
|
|
210
|
-
},
|
|
211
|
-
];
|
|
212
|
-
},
|
|
213
|
-
getProfileMenuItems: () => {
|
|
214
|
-
return [
|
|
215
|
-
{
|
|
216
|
-
label: "Account",
|
|
217
|
-
path: "/account",
|
|
218
|
-
category: "middle",
|
|
219
|
-
icon: UserIcon,
|
|
220
|
-
},
|
|
221
|
-
];
|
|
222
|
-
},
|
|
223
|
-
};
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Event Consumer Plugin
|
|
227
|
-
|
|
228
|
-
```tsx
|
|
229
|
-
import type { ApitogoPlugin } from "@lukoweb/apitogo";
|
|
230
|
-
|
|
231
|
-
const eventConsumerPlugin: ApitogoPlugin = {
|
|
232
|
-
events: {
|
|
233
|
-
location: ({ from, to }) => {
|
|
234
|
-
if (!from) {
|
|
235
|
-
console.log(`Initial navigation to: ${to.pathname}`);
|
|
236
|
-
} else {
|
|
237
|
-
console.log(`Navigation from ${from.pathname} to ${to.pathname}`);
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Transform Config Plugin
|
|
245
|
-
|
|
246
|
-
The `transformConfig` hook allows plugins to modify the APIToGo configuration at build-time. This is
|
|
247
|
-
useful for dynamically adding navigation items, modifying theme settings, or adjusting any other
|
|
248
|
-
configuration based on external data or conditions.
|
|
249
|
-
|
|
250
|
-
```tsx
|
|
251
|
-
import type { ApitogoPlugin } from "@lukoweb/apitogo";
|
|
252
|
-
|
|
253
|
-
const transformConfigPlugin: ApitogoPlugin = {
|
|
254
|
-
transformConfig: ({ config, merge }) => {
|
|
255
|
-
// Option 1: Use merge helper for deep merging
|
|
256
|
-
return merge({
|
|
257
|
-
slots: {
|
|
258
|
-
"head-navigation-start": () => <a href="/pricing">Pricing</a>,
|
|
259
|
-
},
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
// Option 2: Manual spread for full control
|
|
263
|
-
return {
|
|
264
|
-
...config,
|
|
265
|
-
navigation: [
|
|
266
|
-
...(config.navigation ?? []),
|
|
267
|
-
{
|
|
268
|
-
type: "link",
|
|
269
|
-
label: "System Status",
|
|
270
|
-
to: "https://status.example.com",
|
|
271
|
-
icon: "activity",
|
|
272
|
-
},
|
|
273
|
-
],
|
|
274
|
-
};
|
|
275
|
-
},
|
|
276
|
-
};
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
The `transformConfig` function receives an object with:
|
|
280
|
-
|
|
281
|
-
- **config**: The current APIToGo configuration object
|
|
282
|
-
- **merge**: A helper function that deep merges a partial config with the current config
|
|
283
|
-
|
|
284
|
-
The function must return a full configuration object (either via `merge()` or manual spreading), or
|
|
285
|
-
`void` to make no changes. The hook can also be async.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Apache & Nginx
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
APIToGo generates static HTML files for each page during build. Your server must be configured to
|
|
6
|
-
serve these files correctly.
|
|
7
|
-
|
|
8
|
-
## Apache
|
|
9
|
-
|
|
10
|
-
Create a `.htaccess` file in your document root (alongside `index.html`):
|
|
11
|
-
|
|
12
|
-
```apache
|
|
13
|
-
RewriteEngine On
|
|
14
|
-
|
|
15
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
|
16
|
-
RewriteCond %{REQUEST_FILENAME}.html -f
|
|
17
|
-
RewriteRule ^(.*)$ $1.html [L]
|
|
18
|
-
|
|
19
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
|
20
|
-
RewriteCond %{REQUEST_FILENAME} !-d
|
|
21
|
-
RewriteRule ^ index.html [L]
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Requires `mod_rewrite` enabled and `AllowOverride All` in your Apache configuration.
|
|
25
|
-
|
|
26
|
-
## Nginx
|
|
27
|
-
|
|
28
|
-
Add a `try_files` directive to your server block:
|
|
29
|
-
|
|
30
|
-
```nginx
|
|
31
|
-
server {
|
|
32
|
-
listen 80;
|
|
33
|
-
server_name example.com;
|
|
34
|
-
root /var/www/html;
|
|
35
|
-
index index.html;
|
|
36
|
-
|
|
37
|
-
location / {
|
|
38
|
-
try_files $uri $uri.html $uri/ /index.html;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Cloudflare Pages
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
[Pages](https://developers.cloudflare.com/pages) is a low configuration way of publishing your
|
|
6
|
-
documentation.
|
|
7
|
-
|
|
8
|
-
## Prerequisites
|
|
9
|
-
|
|
10
|
-
To publish your site to Cloudflare Pages you will need:
|
|
11
|
-
|
|
12
|
-
- A Cloudflare account
|
|
13
|
-
|
|
14
|
-
Optionally, you may also need:
|
|
15
|
-
|
|
16
|
-
- A GitHub or GitLab account (optional)
|
|
17
|
-
|
|
18
|
-
## Deploying to Pages
|
|
19
|
-
|
|
20
|
-
Cloudflare offers three different ways to create Pages sites.
|
|
21
|
-
|
|
22
|
-
1. Using the [Cloudflare CLI](https://developers.cloudflare.com/pages/get-started/c3/)
|
|
23
|
-
2. Directly uploading the files using
|
|
24
|
-
[drag and drop](https://developers.cloudflare.com/pages/get-started/direct-upload/#drag-and-drop),
|
|
25
|
-
or their
|
|
26
|
-
[Wrangler CLI](https://developers.cloudflare.com/pages/get-started/direct-upload/#wrangler-cli)
|
|
27
|
-
3. Integration with
|
|
28
|
-
[GitHub or GitLab](https://developers.cloudflare.com/pages/get-started/git-integration/)
|
|
29
|
-
|
|
30
|
-
It's up to you which approach you choose but the fastest approach is to use the Wrangler CLI.
|
|
31
|
-
|
|
32
|
-
## Deploy using Wrangler
|
|
33
|
-
|
|
34
|
-
Wrangler makes light work of deploying to Cloudflare Pages, but first you need to get your files in
|
|
35
|
-
order.
|
|
36
|
-
|
|
37
|
-
Build the static version of your documentation site by running:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm run build
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
This will generate a new folder called `dist` that contains all the files that you need to deploy.
|
|
44
|
-
|
|
45
|
-
Next, if you don't already have one, create a new Pages project:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npx wrangler pages project create
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Finally, deploy the files to the new project:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npx wrangler pages deploy ./dist
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Within a few seconds the site will be live and viewable at `<your-project-name>.pages.dev`.
|
|
58
|
-
|
|
59
|
-
## Accurate Last Modified Dates
|
|
60
|
-
|
|
61
|
-
If you have enabled the [`showLastModified`](/docs/configuration/docs#showlastmodified) option,
|
|
62
|
-
APIToGo automatically tracks the last modified date of your documentation pages using Git history.
|
|
63
|
-
However, Cloudflare Pages performs shallow clones by default, which can result in inaccurate "Last
|
|
64
|
-
Modified" dates for pages that haven't been updated recently.
|
|
65
|
-
|
|
66
|
-
To ensure accurate last modified dates when using Git integration with Cloudflare Pages, modify your
|
|
67
|
-
build command to fetch the full history before building:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
git fetch --unshallow && npm run build
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
This command converts the shallow clone to a full clone before running your build, ensuring all
|
|
74
|
-
pages show their correct last modified dates.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Upload/FTP
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
APIToGo can produce a build of static HTML, JavaScript and CSS files that you can deploy directly to
|
|
6
|
-
your own server.
|
|
7
|
-
|
|
8
|
-
## Build locally
|
|
9
|
-
|
|
10
|
-
To prepare the files you need to upload to your server, you will need to use the build command.
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm run build
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Once complete, you will see a new `dist` folder in the root of your project that includes the files
|
|
17
|
-
you need to upload.
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: GitHub Pages
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
[GitHub Pages](https://pages.github.com/) is a great way to publish your documentation, especially
|
|
6
|
-
if you are using GitHub for source control.
|
|
7
|
-
|
|
8
|
-
## Prerequisites
|
|
9
|
-
|
|
10
|
-
To publish your site to GitHub Pages you will need:
|
|
11
|
-
|
|
12
|
-
- A GitHub account
|
|
13
|
-
|
|
14
|
-
## Deploying to GitHub Pages
|
|
15
|
-
|
|
16
|
-
Use the
|
|
17
|
-
[GitHub Actions Workflow](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow).
|
|
18
|
-
|
|
19
|
-
You might need to configure the `basePath` in your site config.ts depending on how your site is
|
|
20
|
-
hosted. For instance, if your site is available at username.github.io/your-repo/ you would set the
|
|
21
|
-
`basePath` to `/your-repo`.
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import type { ApitogoConfig } from "@lukoweb/apitogo";
|
|
25
|
-
|
|
26
|
-
const config: ApitogoConfig = {
|
|
27
|
-
basePath: "/your-repo",
|
|
28
|
-
//...
|
|
29
|
-
};
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Accurate Last Modified Dates
|
|
33
|
-
|
|
34
|
-
If you have enabled the [`showLastModified`](/docs/configuration/docs#showlastmodified) option,
|
|
35
|
-
APIToGo automatically tracks the last modified date of your documentation pages using Git history.
|
|
36
|
-
However, GitHub Actions performs shallow clones by default, which can result in inaccurate "Last
|
|
37
|
-
Modified" dates for pages that haven't been updated recently.
|
|
38
|
-
|
|
39
|
-
To ensure accurate last modified dates, configure the `actions/checkout` step to fetch the full
|
|
40
|
-
history:
|
|
41
|
-
|
|
42
|
-
```yaml
|
|
43
|
-
- uses: actions/checkout@v4
|
|
44
|
-
with:
|
|
45
|
-
fetch-depth: 0 # Fetch all history for all branches and tags
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
For more details, see the
|
|
49
|
-
[actions/checkout documentation](https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches).
|
package/docs/deploy/vercel.md
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Vercel
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
[Vercel](https://vercel.com) offers multiple ways to deploy to its service, including via GitHub,
|
|
6
|
-
and their CLI. You can read more about them in their
|
|
7
|
-
[Deployments Overview](https://vercel.com/docs/deployments/overview).
|
|
8
|
-
|
|
9
|
-
## Prerequisites
|
|
10
|
-
|
|
11
|
-
To deploy to Vercel you will need:
|
|
12
|
-
|
|
13
|
-
- A Vercel account (free)
|
|
14
|
-
- A GitHub account (if deploying via GitHub)
|
|
15
|
-
- The Vercel CLI
|
|
16
|
-
|
|
17
|
-
Deploying your APIToGo powered documentation using the Vercel CLI is what we will cover in this
|
|
18
|
-
guide.
|
|
19
|
-
|
|
20
|
-
## Install the CLI
|
|
21
|
-
|
|
22
|
-
To get started you need to install the CLI:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm i -g vercel
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Setup a new project
|
|
29
|
-
|
|
30
|
-
Next, set up a new Vercel project in the root of your docs:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
vercel
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
This command will set up everything that is needed to deploy your documentation to Vercel.
|
|
37
|
-
|
|
38
|
-
It will ask some specific questions including the project name and where the code is located. You
|
|
39
|
-
can answer however you like for these.
|
|
40
|
-
|
|
41
|
-
When you get to this step:
|
|
42
|
-
|
|
43
|
-
```ansi
|
|
44
|
-
No framework detected. Default Project Settings:
|
|
45
|
-
- Build Command: `npm run vercel-build` or `npm run build`
|
|
46
|
-
- Development Command: None
|
|
47
|
-
- Install Command: `yarn install`, `pnpm install`, `npm install`, or `bun install`
|
|
48
|
-
- Output Directory: `public` if it exists, or `.`
|
|
49
|
-
? Want to modify these settings? (y/N)
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Answer _Yes_ and select to modify the Output Directory.
|
|
53
|
-
|
|
54
|
-
By default Vercel looks for a directory named `public`, but the APIToGo build will be found in
|
|
55
|
-
`dist`. Set the output directory like this:
|
|
56
|
-
|
|
57
|
-
```ansi
|
|
58
|
-
? What's your Output Directory? dist
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
After this is complete, your site will build and Vercel will respond with the URL for you to test
|
|
62
|
-
it.
|
|
63
|
-
|
|
64
|
-
:::tip{title="Clean URLs"}
|
|
65
|
-
|
|
66
|
-
You will almost certainly want to enable clean URLs for your site. This will remove the `.html`
|
|
67
|
-
extension from your URLs. You can do this by adding a `cleanUrls` property to your `vercel.json`
|
|
68
|
-
file. See the
|
|
69
|
-
[Vercel Configuration](https://vercel.com/docs/projects/project-configuration#cleanurls) for more
|
|
70
|
-
information.
|
|
71
|
-
|
|
72
|
-
:::
|
|
73
|
-
|
|
74
|
-
:::caution{title="Redirects"}
|
|
75
|
-
|
|
76
|
-
If you have redirects in `apitogo.config.json`, you may also need matching entries in `vercel.json`.
|
|
77
|
-
See the [Vercel Configuration](https://vercel.com/docs/projects/project-configuration#redirects) for
|
|
78
|
-
more information.
|
|
79
|
-
|
|
80
|
-
This is a current limitation. See [#115](https://github.com/lukoweb/apitogo-doc-tool/issues/151).
|
|
81
|
-
|
|
82
|
-
:::
|
|
83
|
-
|
|
84
|
-
## Accurate Last Modified Dates
|
|
85
|
-
|
|
86
|
-
If you have enabled the [`showLastModified`](/docs/configuration/docs#showlastmodified) option,
|
|
87
|
-
APIToGo automatically tracks the last modified date of your documentation pages using Git history.
|
|
88
|
-
However, Vercel performs shallow clones by default (only fetching the last 10 commits), which can
|
|
89
|
-
result in inaccurate "Last Modified" dates for pages that haven't been updated recently.
|
|
90
|
-
|
|
91
|
-
To ensure accurate last modified dates, add the `VERCEL_DEEP_CLONE` environment variable to your
|
|
92
|
-
Vercel project:
|
|
93
|
-
|
|
94
|
-
1. Go to your project settings in Vercel
|
|
95
|
-
2. Navigate to "Environment Variables"
|
|
96
|
-
3. Add a new variable: `VERCEL_DEEP_CLONE=true`
|
|
97
|
-
4. Save and redeploy your site
|
|
98
|
-
|
|
99
|
-
This will enable full Git history during builds, ensuring all pages show their correct last modified
|
|
100
|
-
dates. The impact on build time is minimal (typically 5-20 seconds on the first build), and
|
|
101
|
-
subsequent builds benefit from caching.
|
package/docs/extending/events.md
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Events
|
|
3
|
-
sidebar_icon: shuffle
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
APIToGo provides an events system that allows plugins to react to various application events. This
|
|
7
|
-
system enables you to build dynamic features that respond to user interactions and application state
|
|
8
|
-
changes.
|
|
9
|
-
|
|
10
|
-
## Available Events
|
|
11
|
-
|
|
12
|
-
Currently, APIToGo supports the following events:
|
|
13
|
-
|
|
14
|
-
### location
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
type LocationEvent = (e: { from?: Location; to: Location }) => void;
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Emitted when the user navigates to a different route. Provides both the previous (`from`) and
|
|
21
|
-
current (`to`)
|
|
22
|
-
[Location objects](https://api.reactrouter.com/v7/interfaces/react_router.Location.html) from
|
|
23
|
-
react-router.
|
|
24
|
-
|
|
25
|
-
Note that the `from` location will be undefined on the initial page load.
|
|
26
|
-
|
|
27
|
-
## Consuming Events in Plugins
|
|
28
|
-
|
|
29
|
-
To consume events in your plugin, you can implement the events property in your plugin. This is
|
|
30
|
-
useful for performing actions like sending analytics events or anything else that's not directly
|
|
31
|
-
related to the UI.
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import type { ApitogoPlugin } from "@lukoweb/apitogo";
|
|
35
|
-
|
|
36
|
-
const navigationLoggerPlugin: ApitogoPlugin = {
|
|
37
|
-
events: {
|
|
38
|
-
location: ({ from, to }) => {
|
|
39
|
-
if (!from) {
|
|
40
|
-
console.log(`Initial navigation to: ${to.pathname}`);
|
|
41
|
-
} else {
|
|
42
|
-
console.log(`User navigated from: ${from.pathname} to: ${to.pathname}`);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Example in APIToGo Config
|
|
50
|
-
|
|
51
|
-
In your your site config, you can define the events like this:
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
export default {
|
|
55
|
-
plugins: [
|
|
56
|
-
{
|
|
57
|
-
events: {
|
|
58
|
-
location: ({ from, to }) => {
|
|
59
|
-
if (!from) return;
|
|
60
|
-
|
|
61
|
-
// E.g. send an analytics event
|
|
62
|
-
sendAnalyticsEvent({
|
|
63
|
-
from: from.pathname,
|
|
64
|
-
to: to.pathname,
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Using Events in Components
|
|
74
|
-
|
|
75
|
-
APIToGo provides a convenient `useEvent` hook to subscribe to events in your React components. The
|
|
76
|
-
hook can be used in three different ways:
|
|
77
|
-
|
|
78
|
-
### 1. Getting the Latest Event Data
|
|
79
|
-
|
|
80
|
-
If you just want to access the latest event data without a callback:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
import { useEvent } from "@lukoweb/apitogo/hooks";
|
|
84
|
-
|
|
85
|
-
function MyComponent() {
|
|
86
|
-
const locationEvent = useEvent("location");
|
|
87
|
-
return <div>Current path: {locationEvent?.to.pathname}</div>;
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### 2. Using Event Data in a Component
|
|
92
|
-
|
|
93
|
-
If you want to transform the event data, return a value from the callback:
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
import { useEvent } from "@lukoweb/apitogo/hooks";
|
|
97
|
-
|
|
98
|
-
function MyComponent() {
|
|
99
|
-
const pathname = useEvent("location", ({ to }) => to.pathname);
|
|
100
|
-
return <div>Current path: {pathname}</div>;
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### 3. Using a Callback for Side Effects
|
|
105
|
-
|
|
106
|
-
If you just want to perform side effects when the event occurs:
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
import { useEvent } from "@lukoweb/apitogo/hooks";
|
|
110
|
-
|
|
111
|
-
function MyComponent() {
|
|
112
|
-
useEvent("location", ({ from, to }) => {
|
|
113
|
-
if (from) {
|
|
114
|
-
console.log(`Navigation: ${from.pathname} → ${to.pathname}`);
|
|
115
|
-
}
|
|
116
|
-
// No return value needed for side effects
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
return <div>My Component</div>;
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
The `useEvent` hook automatically handles subscription and cleanup in the React lifecycle, making it
|
|
124
|
-
easy to work with events in your components.
|