Configuración de StudioCMS
Opciones Disponibles
'Read the “', Opciones Disponibles, '” section'Hay dos formas de configurar la integración de StudioCMS. A continuación se muestran ejemplos de cómo configurar según si eliges usar el archivo astro.config.mjs
o el archivo dedicado studiocms.config.mjs
.
Esta página te muestra cómo y dónde definir la configuración de StudioCMS. Para más información sobre las opciones de configuración de StudioCMS, consulta las páginas de referencia.
Usando el archivo astro.config.mjs
:
'Read the “', Usando el archivo astro.config.mjs:, '” section'import function db(): AstroIntegration[]
db from '@astrojs/db';import function node(userOptions: UserOptions): AstroIntegration
node from '@astrojs/node';import const studioCMS: (options?: { dbStartPage?: boolean | undefined; rendererConfig?: { studiocms?: false | { callouts?: false | { theme?: "github" | "obsidian" | "vitepress" | undefined; } | undefined; autoLinkHeadings?: boolean | undefined; discordSubtext?: boolean | undefined; sanitize?: { allowElements?: string[] | undefined; blockElements?: string[] | undefined; dropElements?: string[] | undefined; allowAttributes?: Record<string, string[]> | undefined; dropAttributes?: Record<string, string[]> | undefined; allowComponents?: boolean | undefined; allowCustomElements?: boolean | undefined; allowComments?: boolean | undefined; } | undefined; } | undefined; renderer?: "studiocms" | CustomRenderer | "astro" | "markdoc" | "mdx" | undefined; markdocConfig?: { renderType?: "html" | MarkdocRenderer | "react-static" | undefined; argParse?: { file?: string | undefined; slots?: boolean | undefined; location?: boolean | undefined; } | undefined; transformConfig?: { tags?: Record<string, {}> | undefined; validation?: { parents?: any[] | undefined; validateFunctions?: boolean | undefined; environment?: string | undefined; } | undefined; nodes ...
StudioCMS Integration
A CMS built for Astro by the Astro Community for the Astro Community.
studioCMS from 'studiocms';import { function defineConfig<const TLocales extends Locales = never, const TDriver extends SessionDriverName = never>(config: AstroUserConfig<TLocales, TDriver>): AstroUserConfig<TLocales, TDriver>
See the full Astro Configuration API Documentation
https://astro.build/config
defineConfig } from 'astro/config';
export default defineConfig<never, never>(config: AstroUserConfig<never, never>): AstroUserConfig<never, never>
See the full Astro Configuration API Documentation
https://astro.build/config
defineConfig({ AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.site?: string
site: 'https://demo.studiocms.dev/', AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.output?: "server" | "static"
output: 'server', AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.adapter?: AstroIntegration
adapter: function node(userOptions: UserOptions): AstroIntegration
node({ UserOptions.mode: "standalone" | "middleware"
Specifies the mode that the adapter builds to.
- 'middleware' - Build to middleware, to be used within another Node.js server, such as Express.
- 'standalone' - Build to a standalone server. The server starts up just by running the built script.
mode: "standalone" }), AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.integrations?: (false | AstroIntegration | (false | AstroIntegration | null | undefined)[] | null | undefined)[]
integrations: [ function db(): AstroIntegration[]
db(), function studioCMS(options?: { dbStartPage?: boolean | undefined; rendererConfig?: { studiocms?: false | { callouts?: false | { theme?: "github" | "obsidian" | "vitepress" | undefined; } | undefined; autoLinkHeadings?: boolean | undefined; discordSubtext?: boolean | undefined; sanitize?: { allowElements?: string[] | undefined; blockElements?: string[] | undefined; dropElements?: string[] | undefined; allowAttributes?: Record<string, string[]> | undefined; dropAttributes?: Record<string, string[]> | undefined; allowComponents?: boolean | undefined; allowCustomElements?: boolean | undefined; allowComments?: boolean | undefined; } | undefined; } | undefined; renderer?: "studiocms" | CustomRenderer | "astro" | "markdoc" | "mdx" | undefined; markdocConfig?: { renderType?: "html" | MarkdocRenderer | "react-static" | undefined; argParse?: { file?: string | undefined; slots?: boolean | undefined; location?: boolean | undefined; } | undefined; transformConfig?: { tags?: Record<string, {}> | undefined; validation?: { parents?: any[] | undefined; validateFunctions?: boolean | undefined; environment?: string | undefined; } | undefined; nodes ...
StudioCMS Integration
A CMS built for Astro by the Astro Community for the Astro Community.
studioCMS({ dbStartPage?: boolean | undefined
dbStartPage: false, // ...Otras opciones de configuración }), ],});
Usando el archivo studiocms.config.mjs
:
'Read the “', Usando el archivo studiocms.config.mjs:, '” section'Este archivo será detectado automáticamente y sobrescribirá cualquier opción pasada en tu astro.config. Si eliges usar esta opción, asegúrate de mover todas las opciones de configuración de StudioCMS a este archivo como se muestra a continuación:
Estructura Ejemplo de Archivos
'Read the “', Estructura Ejemplo de Archivos, '” section'- .env
- astro.config.mjs
- studiocms.config.mjs
- studiocms-auth.config.json Auto Generado
- package.json
Directorysrc
- env.d.ts
- …
Ejemplo de Configuración
'Read the “', Ejemplo de Configuración, '” section'import function db(): AstroIntegration[]
db from '@astrojs/db';import function node(userOptions: UserOptions): AstroIntegration
node from '@astrojs/node';import const studioCMS: (options?: { dbStartPage?: boolean | undefined; rendererConfig?: { studiocms?: false | { callouts?: false | { theme?: "github" | "obsidian" | "vitepress" | undefined; } | undefined; autoLinkHeadings?: boolean | undefined; discordSubtext?: boolean | undefined; sanitize?: { allowElements?: string[] | undefined; blockElements?: string[] | undefined; dropElements?: string[] | undefined; allowAttributes?: Record<string, string[]> | undefined; dropAttributes?: Record<string, string[]> | undefined; allowComponents?: boolean | undefined; allowCustomElements?: boolean | undefined; allowComments?: boolean | undefined; } | undefined; } | undefined; renderer?: "studiocms" | CustomRenderer | "astro" | "markdoc" | "mdx" | undefined; markdocConfig?: { renderType?: "html" | MarkdocRenderer | "react-static" | undefined; argParse?: { file?: string | undefined; slots?: boolean | undefined; location?: boolean | undefined; } | undefined; transformConfig?: { tags?: Record<string, {}> | undefined; validation?: { parents?: any[] | undefined; validateFunctions?: boolean | undefined; environment?: string | undefined; } | undefined; nodes ...
StudioCMS Integration
A CMS built for Astro by the Astro Community for the Astro Community.
studioCMS from 'studiocms';import { function defineConfig<const TLocales extends Locales = never, const TDriver extends SessionDriverName = never>(config: AstroUserConfig<TLocales, TDriver>): AstroUserConfig<TLocales, TDriver>
See the full Astro Configuration API Documentation
https://astro.build/config
defineConfig } from 'astro/config';
export default defineConfig<never, never>(config: AstroUserConfig<never, never>): AstroUserConfig<never, never>
See the full Astro Configuration API Documentation
https://astro.build/config
defineConfig({ AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.site?: string
site: 'https://demo.studiocms.dev/', AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.output?: "server" | "static"
output: 'server', AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.adapter?: AstroIntegration
adapter: function node(userOptions: UserOptions): AstroIntegration
node({ UserOptions.mode: "standalone" | "middleware"
Specifies the mode that the adapter builds to.
- 'middleware' - Build to middleware, to be used within another Node.js server, such as Express.
- 'standalone' - Build to a standalone server. The server starts up just by running the built script.
mode: "standalone" }), AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.integrations?: (false | AstroIntegration | (false | AstroIntegration | null | undefined)[] | null | undefined)[]
integrations: [ function db(): AstroIntegration[]
db(), function studioCMS(options?: { dbStartPage?: boolean | undefined; rendererConfig?: { studiocms?: false | { callouts?: false | { theme?: "github" | "obsidian" | "vitepress" | undefined; } | undefined; autoLinkHeadings?: boolean | undefined; discordSubtext?: boolean | undefined; sanitize?: { allowElements?: string[] | undefined; blockElements?: string[] | undefined; dropElements?: string[] | undefined; allowAttributes?: Record<string, string[]> | undefined; dropAttributes?: Record<string, string[]> | undefined; allowComponents?: boolean | undefined; allowCustomElements?: boolean | undefined; allowComments?: boolean | undefined; } | undefined; } | undefined; renderer?: "studiocms" | CustomRenderer | "astro" | "markdoc" | "mdx" | undefined; markdocConfig?: { renderType?: "html" | MarkdocRenderer | "react-static" | undefined; argParse?: { file?: string | undefined; slots?: boolean | undefined; location?: boolean | undefined; } | undefined; transformConfig?: { tags?: Record<string, {}> | undefined; validation?: { parents?: any[] | undefined; validateFunctions?: boolean | undefined; environment?: string | undefined; } | undefined; nodes ...
StudioCMS Integration
A CMS built for Astro by the Astro Community for the Astro Community.
studioCMS() ],});
import { function defineStudioCMSConfig(config: StudioCMSOptions): { dbStartPage?: boolean | undefined; rendererConfig?: { studiocms?: false | { callouts?: false | { theme?: "github" | "obsidian" | "vitepress" | undefined; } | undefined; autoLinkHeadings?: boolean | undefined; discordSubtext?: boolean | undefined; sanitize?: { allowElements?: string[] | undefined; blockElements?: string[] | undefined; dropElements?: string[] | undefined; allowAttributes?: Record<string, string[]> | undefined; dropAttributes?: Record<string, string[]> | undefined; allowComponents?: boolean | undefined; allowCustomElements?: boolean | undefined; allowComments?: boolean | undefined; } | undefined; } | undefined; renderer?: "studiocms" | CustomRenderer | "astro" | "markdoc" | "mdx" | undefined; markdocConfig?: { renderType?: "html" | MarkdocRenderer | "react-static" | undefined; argParse?: { file?: string | undefined; slots?: boolean | undefined; location?: boolean | undefined; } | undefined; transformConfig?: { tags?: Record<string, {}> | undefined; validation?: { parents?: any[] | undefined; validateFunctions?: boolean | undefined; environment?: string | undefined; } | undefined;...
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs
. And it should be adjacent
to the Astro project's astro.config.mjs
file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
defineStudioCMSConfig } from "studiocms/config";
export default function defineStudioCMSConfig(config: StudioCMSOptions): { dbStartPage?: boolean | undefined; rendererConfig?: { studiocms?: false | { callouts?: false | { theme?: "github" | "obsidian" | "vitepress" | undefined; } | undefined; autoLinkHeadings?: boolean | undefined; discordSubtext?: boolean | undefined; sanitize?: { allowElements?: string[] | undefined; blockElements?: string[] | undefined; dropElements?: string[] | undefined; allowAttributes?: Record<string, string[]> | undefined; dropAttributes?: Record<string, string[]> | undefined; allowComponents?: boolean | undefined; allowCustomElements?: boolean | undefined; allowComments?: boolean | undefined; } | undefined; } | undefined; renderer?: "studiocms" | CustomRenderer | "astro" | "markdoc" | "mdx" | undefined; markdocConfig?: { renderType?: "html" | MarkdocRenderer | "react-static" | undefined; argParse?: { file?: string | undefined; slots?: boolean | undefined; location?: boolean | undefined; } | undefined; transformConfig?: { tags?: Record<string, {}> | undefined; validation?: { parents?: any[] | undefined; validateFunctions?: boolean | undefined; environment?: string | undefined; } | undefined;...
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs
. And it should be adjacent
to the Astro project's astro.config.mjs
file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
defineStudioCMSConfig({ dbStartPage?: boolean | undefined
dbStartPage: false, // ...Otras opciones de configuración})