@studiocms/blog
Ce module d’extension active les fonctionnalités du blog StudioCMS ainsi qu’un front-end dans votre projet Astro. Il vous permettra de créer, modifier et supprimer des articles de blog depuis le tableau de bord de StudioCMS.
Que fait ce module d’extension ?
Section intitulée « Que fait ce module d’extension ? »Cette intégration ajoutera les nouvelles routes suivantes à votre front-end contrôlé par StudioCMS :
/[...slug]
- Route fourre-tout générant les pages génériques de StudioCMS./blog
- Index du blog répertoriant tous les articles./blog/[slug]
- La page individuelle de l’article de blog./rss.xml
- Le flux RSS de vos articles de blog.
Installation
Section intitulée « Installation »-
Installez le paquet à l’aide de la commande suivante :
Fenêtre de terminal npm run studiocms add @studiocms/blogFenêtre de terminal pnpm run studiocms add @studiocms/blogFenêtre de terminal yarn run studiocms add @studiocms/blog -
Votre configuration StudioCMS devrait désormais inclure
@studiocms/blog
:studiocms.config.mjs import {defineStudioCMSConfig } from 'studiocms/config';function defineStudioCMSConfig(config: StudioCMSOptions): {plugins?: StudioCMSPlugin[] | undefined;logLevel?: "All" | "Fatal" | "Error" | "Warning" | "Info" | "Debug" | "Trace" | "None" | undefined;dbStartPage?: boolean | undefined;verbose?: boolean | undefined;componentRegistry?: Record<string, string> | undefined;locale?: {dateLocale?: string | undefined;dateTimeFormat?: Intl.DateTimeFormatOptions | undefined;} | undefined;features?: {sdk?: boolean | {cacheConfig?: boolean | {lifetime?: string | undefined;} | undefined;} | undefined;robotsTXT?: boolean | {host?: string | boolean | undefined;sitemap?: string | boolean | string[] | undefined;policy?: {userAgent?: "360Spider" | "360Spider-Image" | "360Spider-Video" | "HaoSouSpider" | "AdsBot-Google" | "AdsBot-Google-Mobile" | "AdsBot-Google-Mobile-Apps" | "Googlebot" | "Googlebot-Image" | "Googlebot-Mobile" | "Googlebot-News" | "Googlebot-Video" | "Mediapartners-Google" | "adidxbot" | "bingbot" | "BingPreview" | "MicrosoftPreview" | "msnbot" | "msnbot-media" | "Applebot" | "AppleNewsBot" | "Baiduspider" | "Baiduspider-image" | "Baiduspider-mobile" | "Baiduspider-news" | "Baiduspider-video" | "coccoc" | "coccocbot-image" | "coccocbot-web" | "DuckDuckBot" | "DuckDuckGo-Favicons-Bot" | "facebookcatalog" | "facebookexternalhit" | "Facebot" | "gooblog" | "ichiro" | "Sogou blog" | "Sogou inst spider" | "Sogou News Spider" | "Sogou Orion spider" | "Sogou spider2" | "Sogou web spider" ...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'sastro.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.
importblog from '@studiocms/blog';function blog(options?: StudioCMSBlogOptions): StudioCMSPluginCreates and configures the StudioCMS Blog plugin.
export defaultdefineStudioCMSConfig({function defineStudioCMSConfig(config: StudioCMSOptions): {plugins?: StudioCMSPlugin[] | undefined;logLevel?: "All" | "Fatal" | "Error" | "Warning" | "Info" | "Debug" | "Trace" | "None" | undefined;dbStartPage?: boolean | undefined;verbose?: boolean | undefined;componentRegistry?: Record<string, string> | undefined;locale?: {dateLocale?: string | undefined;dateTimeFormat?: Intl.DateTimeFormatOptions | undefined;} | undefined;features?: {sdk?: boolean | {cacheConfig?: boolean | {lifetime?: string | undefined;} | undefined;} | undefined;robotsTXT?: boolean | {host?: string | boolean | undefined;sitemap?: string | boolean | string[] | undefined;policy?: {userAgent?: "360Spider" | "360Spider-Image" | "360Spider-Video" | "HaoSouSpider" | "AdsBot-Google" | "AdsBot-Google-Mobile" | "AdsBot-Google-Mobile-Apps" | "Googlebot" | "Googlebot-Image" | "Googlebot-Mobile" | "Googlebot-News" | "Googlebot-Video" | "Mediapartners-Google" | "adidxbot" | "bingbot" | "BingPreview" | "MicrosoftPreview" | "msnbot" | "msnbot-media" | "Applebot" | "AppleNewsBot" | "Baiduspider" | "Baiduspider-image" | "Baiduspider-mobile" | "Baiduspider-news" | "Baiduspider-video" | "coccoc" | "coccocbot-image" | "coccocbot-web" | "DuckDuckBot" | "DuckDuckGo-Favicons-Bot" | "facebookcatalog" | "facebookexternalhit" | "Facebot" | "gooblog" | "ichiro" | "Sogou blog" | "Sogou inst spider" | "Sogou News Spider" | "Sogou Orion spider" | "Sogou spider2" | "Sogou web spider" ...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'sastro.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.
plugins: [plugins?: StudioCMSPlugin[] | undefinedblog(/* Options */),function blog(options?: StudioCMSBlogOptions): StudioCMSPluginCreates and configures the StudioCMS Blog plugin.
],});
type StudioCMSBlogOptions = { /** * Langue par défaut du HTML - La langue par défaut de la balise HTML * @default 'en' */ htmlDefaultLanguage: string | undefined; /** * En-tête HTML par défaut - La configuration d'en-tête par défaut pour le frontend */ htmlDefaultHead: { /** * Nom de la balise HTML à ajouter dans `<head>`, par exemple `'meta'`, `'link'` ou `'script'`. */ tag: "link" | "title" | "base" | "style" | "meta" | "script" | "noscript" | "template"; /** * Attributs à définir sur la balise, par exemple `{ rel: 'stylesheet', href: '/custom.css' }`. */ attrs?: Record<string, string | boolean | undefined> | undefined; /** * Contenu à placer à l'intérieur de la balise (facultatif). */ content?: string | undefined; }[] | undefined; /** * Configuration du favicon - La configuration du favicon par défaut pour le frontend */ favicon: string | undefined; /** * Active la génération du plan du site * @default true */ sitemap: boolean | undefined; /** * Injecte les routes * @default true */ injectRoutes: boolean | undefined; /** * La configuration du blog */ blog: { /** * Le titre du blog */ title: string | undefined; /** * Active le flux RSS */ enableRSS: boolean | undefined; /** * La route du blog * @default '/blog' * @example '/nouvelles' */ route: string | undefined; } | undefined;}