astro-loader-i18n
Version:
An Astro content loader for i18n files and folder structures.
125 lines (124 loc) • 4.1 kB
TypeScript
import { AnyZodObject, z } from 'astro/zod';
/**
* Schema definition for the i18n loader configuration.
* This schema validates the structure of the i18n loader object.
*
* Properties:
* - `translationId` (string): A unique identifier for the translation.
* - `locale` (string): The locale code (e.g., "en", "fr", "es") for the translation.
* - `contentPath` (string): The path from the contents root to the content file.
* - `basePath` (string): The base directory path of your website. This is used by i18nPropsAndParams to provide paths with a base path.
*/
export declare const i18nLoaderSchema: z.ZodObject<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, "strip", z.ZodTypeAny, {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
}, {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
}>;
/**
* Extends the base `i18nLoaderSchema` with additional schema definitions.
*
* @template Z - A Zod object schema that will be merged with the base schema.
* @param schema - The Zod schema to extend the base `i18nLoaderSchema`.
* @returns A new schema resulting from merging the base `i18nLoaderSchema` with the provided schema.
*/
export declare const extendI18nLoaderSchema: <Z extends AnyZodObject>(schema: Z) => z.ZodObject<z.objectUtil.extendShape<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, Z["shape"]>, Z["_def"]["unknownKeys"], Z["_def"]["catchall"], z.objectOutputType<z.objectUtil.extendShape<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, Z["shape"]>, Z["_def"]["catchall"], Z["_def"]["unknownKeys"]>, z.objectInputType<z.objectUtil.extendShape<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, Z["shape"]>, Z["_def"]["catchall"], Z["_def"]["unknownKeys"]>>;
declare const i18nLoaderEntrySchema: z.ZodObject<{
data: z.ZodObject<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, "strip", z.ZodTypeAny, {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
}, {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
}>;
filePath: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
data: {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
};
filePath?: string | undefined;
}, {
data: {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
};
filePath?: string | undefined;
}>;
export type I18nLoaderEntry = z.infer<typeof i18nLoaderEntrySchema>;
declare const i18nLoaderCollectionSchema: z.ZodArray<z.ZodObject<{
data: z.ZodObject<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, "strip", z.ZodTypeAny, {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
}, {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
}>;
filePath: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
data: {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
};
filePath?: string | undefined;
}, {
data: {
locale: string;
translationId: string;
contentPath: string;
basePath: string;
};
filePath?: string | undefined;
}>, "many">;
export type I18nLoaderCollection = z.infer<typeof i18nLoaderCollectionSchema>;
export declare function checkI18nLoaderCollection(obj: unknown): asserts obj is I18nLoaderCollection;
export {};