mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
feat(next): envField jsdoc (#11927)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
This commit is contained in:
parent
a8a3d2cde8
commit
5b4e3abbb1
2 changed files with 46 additions and 1 deletions
5
.changeset/pink-yaks-exercise.md
Normal file
5
.changeset/pink-yaks-exercise.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Updates the `env` configuration reference docs to include a full API reference for `envField`.
|
|
@ -1438,7 +1438,7 @@ export interface AstroUserConfig {
|
|||
* @version 5.0.0
|
||||
* @description
|
||||
*
|
||||
* An object that uses `envField` to define the data type (`string`, `number`, or `boolean`) and properties of your environment variables: `context` (client or server), `access` (public or secret), a `default` value to use, and whether or not this environment variable is `optional` (defaults to `false`).
|
||||
* An object that uses `envField` to define the data type and properties of your environment variables: `context` (client or server), `access` (public or secret), a `default` value to use, and whether or not this environment variable is `optional` (defaults to `false`).
|
||||
* ```js
|
||||
* // astro.config.mjs
|
||||
* import { defineConfig, envField } from "astro/config"
|
||||
|
@ -1453,6 +1453,46 @@ export interface AstroUserConfig {
|
|||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* `envField` supports four data types: string, number, enum, and boolean. `context` and `access` are required properties for all data types. The following shows the complete list of properties available for each data type:
|
||||
*
|
||||
* ```js
|
||||
* import { envField } from "astro/config"
|
||||
*
|
||||
* envField.string({
|
||||
* // context & access
|
||||
* optional: true,
|
||||
* default: "foo",
|
||||
* max: 20,
|
||||
* min: 1,
|
||||
* length: 13,
|
||||
* url: true,
|
||||
* includes: "oo",
|
||||
* startsWith: "f",
|
||||
* endsWith: "o",
|
||||
* })
|
||||
* envField.number({
|
||||
* // context & access
|
||||
* optional: true,
|
||||
* default: 15,
|
||||
* gt: 2,
|
||||
* min: 1,
|
||||
* lt: 3,
|
||||
* max: 4,
|
||||
* int: true,
|
||||
* })
|
||||
* envField.boolean({
|
||||
* // context & access
|
||||
* optional: true,
|
||||
* default: true,
|
||||
* })
|
||||
* envField.enum({
|
||||
* // context & access
|
||||
* values: ['foo', 'bar', 'baz'], // required
|
||||
* optional: true,
|
||||
* default: 'baz',
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
schema?: EnvSchema;
|
||||
|
||||
|
|
Loading…
Reference in a new issue