Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions customize/custom-scripts.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Custom scripts"
description: "Add custom JavaScript and CSS scripts to your documentation site for analytics, widgets, styling overrides, and third-party integrations."
keywords: ["CSS", "JavaScript", "Tailwind CSS", "style customization"]
description: "Add custom JavaScript and CSS for analytics, widgets, styling, third-party integrations, and API Playground server variables on your documentation site."
keywords: ["CSS", "JavaScript", "Tailwind CSS", "style customization", "API Playground", "server variables"]
---

Use CSS to style HTML elements or add custom CSS and JavaScript to fully customize the look and feel of your documentation.
Expand Down Expand Up @@ -269,7 +269,7 @@
- `contextual-feedback-form-submit-button` — Submit button for the contextual feedback form.
</Accordion>
<Accordion title="Code snippet feedback">
- `code-snippet-feedback-popover-content` — Popover content for code snippet feedback.

Check warning on line 272 in customize/custom-scripts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

customize/custom-scripts.mdx#L272

Use 'popover' instead of 'Popover'.
- `code-snippet-feedback-form` — Feedback form for a code snippet.
- `code-snippet-feedback-textarea` — Text area within the code snippet feedback form.
- `code-snippet-feedback-form-title` — Title of the code snippet feedback form.
Expand Down Expand Up @@ -388,11 +388,35 @@
Use with caution to avoid introducing security vulnerabilities.
</Warning>

### Set API Playground server variables

Use `window.mintlify.api.playground.setServerVariables` to prefill [OpenAPI server variables](/api-playground/openapi-setup) from custom JavaScript. Use it when values become available after page load. For example, after authentication or a tenant change.

Pass an object of string values. Each call replaces the previous runtime values, which take precedence over OpenAPI defaults and saved values.

```js Set API Playground server variables
window.mintlify.api.playground.setServerVariables({
tenantDomain: 'example.us.auth0.com',
});
```

To remove the runtime values, call:

```js Clear API Playground server variables
window.mintlify.api.playground.clearServerVariables();
```

Calls made before the client initializes queue. Values apply to open and future playgrounds for the current page session and reset after a full-page refresh.

<Warning>
Do not use server variables for API keys, tokens, or other secrets.
</Warning>

### Access authenticated user data

If your site uses [authentication](/deploy/authentication-setup), custom scripts can read the signed-in user from `window.mintlify.user`. This is the same object exposed to MDX pages as the [`user` variable](/create/personalization#dynamic-mdx-content), so it reflects the `content` field of your user data.

Because custom scripts run before user info resolves, listen for the `mintlify:user` event to identify when the user object is available. The event fires when user info resolves and again on any change. Its `detail` is the user object, or `null` when the visitor is signed out.

Check warning on line 419 in customize/custom-scripts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

customize/custom-scripts.mdx#L419

In general, use active voice instead of passive voice ('is signed').

```js Read the user after it resolves
window.addEventListener('mintlify:user', (event) => {
Expand All @@ -412,7 +436,7 @@
}
```

`window.mintlify.user` is `undefined` until user info resolves and when the visitor is signed out. Use optional chaining when reading nested fields.

Check warning on line 439 in customize/custom-scripts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

customize/custom-scripts.mdx#L439

In general, use active voice instead of passive voice ('is signed').

<Warning>
Client-side scripts can access anything you place in the user `content` field. Do not include secrets or credentials that shouldn't be readable in the browser.
Expand Down
30 changes: 28 additions & 2 deletions es/customize/custom-scripts.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Scripts personalizados"
description: "Agrega JavaScript y CSS personalizados a tu sitio de documentación para analíticas, widgets, personalización de estilos e integraciones con terceros."
keywords: ["CSS", "JavaScript", "Tailwind CSS", "personalización de estilo"]
description: "Agrega JavaScript y CSS personalizados a tu documentación para analíticas, widgets, estilos, integraciones y variables de servidor del API Playground."
keywords: ["CSS", "JavaScript", "Tailwind CSS", "personalización de estilo", "API Playground", "variables de servidor"]
---

Usa CSS para dar estilo a los elementos HTML o agrega CSS y JavaScript personalizados para adaptar por completo el aspecto y la experiencia de tu documentación.
Expand Down Expand Up @@ -408,6 +408,32 @@ gtag('config', 'TAG_ID');
Úsalo con precaución para no introducir vulnerabilidades de seguridad.
</Warning>

<div id="set-api-playground-server-variables">
### Configura las variables de servidor del API Playground
</div>

Usa `window.mintlify.api.playground.setServerVariables` para rellenar previamente [las variables de servidor de OpenAPI](/es/api-playground/openapi-setup) desde JavaScript personalizado. Úsalo cuando los valores estén disponibles después de cargar la página, por ejemplo, al inicializarse un SDK de autenticación o cambiar un inquilino. El método actualiza los API Playgrounds abiertos y se aplica a los que abras después.

Pasa un objeto con valores de tipo string. Cada llamada reemplaza por completo la sobreescritura en tiempo de ejecución. Las claves omitidas se eliminan y los valores no válidos se ignoran. Los valores en tiempo de ejecución tienen prioridad sobre los valores predeterminados de OpenAPI y las variables de servidor guardadas.

```js Set API Playground server variables
window.mintlify.api.playground.setServerVariables({
tenantDomain: 'example.us.auth0.com',
});
```

Llama a `window.mintlify.api.playground.clearServerVariables()` cuando los valores ya no se apliquen, por ejemplo, después de cerrar sesión. Después de borrarlos, el API Playground vuelve a sus otros valores configurados.

```js Clear API Playground server variables
window.mintlify.api.playground.clearServerVariables();
```

Las llamadas realizadas antes de que se inicialice el cliente se ponen en cola y se aplican cuando se inicializa. La sobreescritura se mantiene en memoria durante la sesión de la página. No escribe en `localStorage` ni en el almacenamiento de credenciales. Una actualización completa de la página la elimina.

<Warning>
Configura únicamente valores que no sean secretos desde el código del cliente. No incluyas claves de API, tokens ni otras credenciales en las variables de servidor.
</Warning>

<div id="access-authenticated-user-data">
### Acceder a los datos del usuario autenticado
</div>
Expand Down
30 changes: 28 additions & 2 deletions fr/customize/custom-scripts.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Scripts personnalisés"
description: "Ajoutez du JavaScript et du CSS personnalisés à votre documentation pour les analyses, widgets, ajustements de styles et intégrations tierces."
keywords: ["CSS", "JavaScript", "Tailwind CSS", "personnalisation du style"]
description: "Ajoutez du JavaScript et du CSS à votre documentation pour les analyses, widgets, styles, intégrations tierces et variables de serveur de l'API Playground."
keywords: ["CSS", "JavaScript", "Tailwind CSS", "personnalisation du style", "API Playground", "variables de serveur"]
---

Utilisez CSS pour mettre en forme les éléments HTML, ou ajoutez du CSS et du JavaScript personnalisés afin d'adapter entièrement l'apparence et l'expérience de votre documentation.
Expand Down Expand Up @@ -408,6 +408,32 @@ gtag('config', 'TAG_ID');
Veuillez l'utiliser avec prudence afin de ne pas introduire de vulnérabilités de sécurité.
</Warning>

<div id="set-api-playground-server-variables">
### Définir les variables de serveur de l'API Playground
</div>

Utilisez `window.mintlify.api.playground.setServerVariables` pour préremplir [les variables de serveur OpenAPI](/fr/api-playground/openapi-setup) depuis votre JavaScript personnalisé. Utilisez-la lorsque les valeurs deviennent disponibles après le chargement de la page, par exemple après l'initialisation d'un SDK d'authentification ou un changement de locataire. La méthode met à jour les API Playgrounds ouverts et s'applique aux prochains Playgrounds.

Transmettez un objet dont les valeurs sont des chaînes. Chaque appel remplace entièrement la surcharge d'exécution. Les clés omises sont supprimées et les valeurs non valides sont ignorées. Les valeurs d'exécution sont prioritaires sur les valeurs par défaut OpenAPI et les variables de serveur enregistrées.

```js Set API Playground server variables
window.mintlify.api.playground.setServerVariables({
tenantDomain: 'example.us.auth0.com',
});
```

Appelez `window.mintlify.api.playground.clearServerVariables()` lorsque ces valeurs ne s'appliquent plus, par exemple après une déconnexion. Après la suppression, l'API Playground revient à ses autres valeurs configurées.

```js Clear API Playground server variables
window.mintlify.api.playground.clearServerVariables();
```

Les appels effectués avant l'initialisation du client sont mis en file d'attente, puis appliqués lors de son initialisation. La surcharge reste en mémoire pendant la session de la page. Elle n'écrit ni dans `localStorage` ni dans le stockage des identifiants. Un rechargement complet de la page la supprime.

<Warning>
Définissez uniquement des valeurs non secrètes depuis le code côté client. N'incluez pas de clés d'API, de jetons ou d'autres identifiants dans les variables de serveur.
</Warning>

<div id="access-authenticated-user-data">
### Accéder aux données de l'utilisateur authentifié
</div>
Expand Down
30 changes: 28 additions & 2 deletions zh/customize/custom-scripts.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "自定义脚本"
description: "为你的文档站点添加自定义 JavaScript 和 CSS 脚本,用于分析、小组件、样式覆盖和第三方集成。"
keywords: ["CSS", "JavaScript", "Tailwind CSS", "样式定制"]
description: "为你的文档站点添加自定义 JavaScript 和 CSS,用于分析、小组件、样式覆盖、第三方集成和 API Playground 服务器变量。支持身份验证、租户切换和注销后的运行时更新,值仅保存在当前会话内存中,不会写入浏览器存储。"
keywords: ["CSS", "JavaScript", "Tailwind CSS", "样式定制", "API Playground", "服务器变量"]
---

使用 CSS 为 HTML 元素设置样式,或添加自定义 CSS 和 JavaScript,全面定制文档的外观与使用体验。
Expand Down Expand Up @@ -408,6 +408,32 @@ gtag('config', 'TAG_ID');
请谨慎使用,避免造成安全漏洞。
</Warning>

<div id="set-api-playground-server-variables">
### 设置 API Playground 服务器变量
</div>

使用 `window.mintlify.api.playground.setServerVariables`,通过自定义 JavaScript 预填充 [OpenAPI 服务器变量](/zh/api-playground/openapi-setup)。当页面加载后才能获得这些值时使用此方法,例如身份验证 SDK 初始化完成或租户发生变化时。该方法会立即更新已打开的 API Playground,也会应用到之后打开的 Playground。

传入一个值为字符串的对象。每次调用都会替换完整的运行时覆盖值。省略的键会被移除,无效值会被忽略。运行时值优先于 OpenAPI 默认值和已保存的服务器变量。

```js Set API Playground server variables
window.mintlify.api.playground.setServerVariables({
tenantDomain: 'example.us.auth0.com',
});
```

当这些值不再适用时调用 `window.mintlify.api.playground.clearServerVariables()`,例如注销后。清除后,API Playground 会回退到其他已配置的值。

```js Clear API Playground server variables
window.mintlify.api.playground.clearServerVariables();
```

在客户端初始化之前发出的调用会进入队列,并在客户端初始化时应用。覆盖值仅在当前页面会话的内存中保留。不会写入 `localStorage` 或凭据存储。完整刷新页面会移除覆盖值。

<Warning>
只能从客户端代码设置非机密值。不要在服务器变量中包含 API 密钥、令牌或其他凭据。
</Warning>

<div id="access-authenticated-user-data">
### 访问已登录用户的数据
</div>
Expand Down