astro-loader-i18n
Version:
An Astro content loader for i18n files and folder structures.
61 lines (60 loc) • 2.83 kB
TypeScript
import { 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;
}, z.core.$strip>;
/**
* Extends the base `i18nLoaderSchema` with additional schema definitions.
*
* @template Shape - A Zod object shape to extend the base schema with.
* @param schema - The Zod schema to extend the base `i18nLoaderSchema`.
* @returns A new schema resulting from extending the base `i18nLoaderSchema` with the provided schema shape.
*/
type ZodObjectLike<Shape extends z.ZodRawShape = z.ZodRawShape> = {
shape: Shape;
};
export declare const extendI18nLoaderSchema: <Shape extends z.ZodRawShape>(schema: ZodObjectLike<Shape>) => z.ZodObject<(("locale" | "translationId" | "contentPath" | "basePath") & keyof Shape extends never ? {
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
} & { -readonly [P in keyof Shape]: Shape[P]; } : ({
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof Shape ? never : K]: T_1[K]; } : never) & { [K_1 in keyof { -readonly [P in keyof Shape]: Shape[P]; }]: { -readonly [P in keyof Shape]: Shape[P]; }[K_1]; }) extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
declare const i18nLoaderEntrySchema: z.ZodObject<{
data: z.ZodObject<{
translationId: z.ZodString;
locale: z.ZodString;
contentPath: z.ZodString;
basePath: z.ZodString;
}, z.core.$strip>;
filePath: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
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;
}, z.core.$strip>;
filePath: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
export type I18nLoaderCollection = z.infer<typeof i18nLoaderCollectionSchema>;
export declare function checkI18nLoaderCollection(obj: unknown): asserts obj is I18nLoaderCollection;
export {};