2025-09-05 14:59:21 +08:00

81 lines
2.6 KiB
TypeScript

import { ComputedRef, Ref } from 'vue';
interface SiteConfigResolved {
/**
* The canonical Site URL.
*
* - Build / Prerender: Inferred from CI environment (Netlify, Vercel)
* - SSR: Inferred from request headers
* - SPA: Inferred from `window.location`
*
* Used by: nuxt-simple-sitemap, nuxt-simple-robots, nuxt-schema-org, nuxt-og-image, etc.
*/
url?: string;
/**
* The name of the site.
*
* - Build / Prerender: Inferred from CI environment (Netlify) or `package.json`
* - SSR:
*
* Used by: nuxt-schema-org, nuxt-seo-kit
*/
name?: string;
/**
* Whether the site is indexable by search engines.
*
* Allows you to opt-out productions environment from being indexed.
*/
indexable?: boolean;
/**
* The environment of the site. Comparable to `process.env.NODE_ENV`.
*/
env?: 'production' | 'staging' | 'development' | 'preview' | 'uat' | string;
/**
* Whether the site uses trailing slash.
*/
trailingSlash?: boolean;
/**
* The mapping of the context of each site config value being set.
*/
_context?: Record<string, string>;
/**
* Support any keys as site config.
*/
[key: string]: any;
}
/**
* @deprecated use SiteConfigResolved
*/
type SiteConfig = SiteConfigResolved;
type MaybeComputedRef<T> = T | (() => T) | ComputedRef<T> | Ref<T>;
type MaybeComputedRefEntries<T> = {
[key in keyof T]?: MaybeComputedRef<T[key]>;
};
type SiteConfigInput = Omit<MaybeComputedRefEntries<Partial<SiteConfigResolved>>, '_context' | 'indexable'> & {
_context?: string;
_priority?: number;
indexable?: MaybeComputedRef<string | boolean>;
};
interface GetSiteConfigOptions {
debug?: boolean;
skipNormalize?: boolean;
resolveRefs?: boolean;
}
interface SiteConfigStack {
stack: Partial<SiteConfigInput>[];
push: (config: SiteConfigInput) => void;
get: (options?: GetSiteConfigOptions) => SiteConfigResolved;
}
declare function normalizeSiteConfig(config: SiteConfigResolved): SiteConfigResolved;
declare function validateSiteConfigStack(stack: SiteConfigStack): string[];
declare function createSiteConfigStack(options?: {
debug: boolean;
}): SiteConfigStack;
declare function envSiteConfig(env: Record<string, any>): {
[k: string]: any;
};
export { type GetSiteConfigOptions, type MaybeComputedRef, type MaybeComputedRefEntries, type SiteConfig, type SiteConfigInput, type SiteConfigResolved, type SiteConfigStack, createSiteConfigStack, envSiteConfig, normalizeSiteConfig, validateSiteConfigStack };