@astrojs/web-vitals
该 Astro 集成支持跟踪真实世界的网站性能数据并将数据存储在 Astro DB 中。这些数据会在 StudioCMS 仪表盘中展示您的网站随时间变化的真实性能指标。
-
安装软件包并将其添加到 Astro 配置中:
Terminal window npx astro add @astrojs/web-vitalsTerminal window pnpm astro add @astrojs/web-vitalsTerminal window yarn astro add @astrojs/web-vitals -
将新配置推送到您的远程数据库:
Terminal window npx astro db pushTerminal window pnpm astro db pushTerminal window yarn astro db push
-
使用以下命令安装软件包:
Terminal window npm i @astrojs/web-vitalsTerminal window pnpm add @astrojs/web-vitalsTerminal window yarn add @astrojs/web-vitals -
将
@astrojs/web-vitals
添加到您的 Astro 配置文件:astro.config.mjs importnode from '@astrojs/node';function node(userOptions: UserOptions): AstroIntegrationimportstudioCMS from 'studiocms';const studioCMS: (options?: {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" | "Yandex" | "YandexMobileBot" ...StudioCMS Integration
A CMS built for Astro by the Astro Community for the Astro Community.
importdb from '@astrojs/db';function db(): AstroIntegration[]importwebVitals from '@astrojs/web-vitals'; // 导入网页指标集成import webVitalsError ts(2307) ―import {defineConfig } from 'astro/config';function defineConfig<const TLocales extends Locales = never, const TDriver extends SessionDriverName = never, const TFontFamilies extends FontFamily[] = never>(config: AstroUserConfig<TLocales, TDriver, TFontFamilies>): AstroUserConfig<TLocales, TDriver, TFontFamilies>See the full Astro Configuration API Documentation https://astro.build/config
export defaultdefineConfig({defineConfig<never, never, never>(config: AstroUserConfig<never, never, never>): AstroUserConfig<never, never, never>See the full Astro Configuration API Documentation https://astro.build/config
site: 'https://demo.studiocms.dev/',AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never, TFontFamilies extends FontFamily[] = never>.site?: stringoutput: 'server',AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never, TFontFamilies extends FontFamily[] = never>.output?: "server" | "static"adapter:AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never, TFontFamilies extends FontFamily[] = never>.adapter?: AstroIntegrationnode({function node(userOptions: UserOptions): AstroIntegrationmode: "standalone" }),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.
integrations: [AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never, TFontFamilies extends FontFamily[] = never>.integrations?: (false | AstroIntegration | (false | AstroIntegration | null | undefined)[] | null | undefined)[]db(), // 必须项function db(): AstroIntegration[]webVitals(), // 启用网页指标跟踪import webVitalsstudioCMS(), // StudioCMS 核心集成function studioCMS(options?: {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" | "Yandex" | "YandexMobileBot" ...StudioCMS Integration
A CMS built for Astro by the Astro Community for the Astro Community.
],}); -
将新配置推送到您的远程数据库:
Terminal window npx astro db pushTerminal window pnpm astro db pushTerminal window yarn astro db push