1 | import { StaticPath, StaticPropsContext } from './scripts/build';
|
2 | import { ComponentProps, JSX, ComponentType } from "preact";
|
3 | declare type RestParam<S extends string> = S extends `...${infer A}` ? A : never;
|
4 | declare type StandardParam<S extends string> = S extends `...${infer A}` ? never : S;
|
5 | declare type ExtractParams<S extends string> = S extends `[${infer A}]` ? A : never;
|
6 | declare type TupleToUnion<T extends any[]> = T[number];
|
7 | declare type Split<S extends string> = string extends S ? string[] : S extends '' ? [] : S extends `${infer T}/${infer U}` ? [T, ...Split<U>] : [
|
8 | S
|
9 | ];
|
10 | declare type NormalizePath<S extends string> = S extends `/${infer T}` ? T : S;
|
11 | declare type AllPathParams<S extends string, P extends string = ExtractParams<TupleToUnion<Split<NormalizePath<S>>>>> = {
|
12 | [param in P]: string | string[];
|
13 | };
|
14 | declare type RestParams<S extends string, Base extends string = keyof AllPathParams<S>> = {
|
15 | [a in RestParam<Base>]: string[];
|
16 | };
|
17 | declare type StandardParams<S extends string, Base extends string = keyof AllPathParams<S>> = {
|
18 | [a in StandardParam<Base>]: string;
|
19 | };
|
20 | export declare type PathParams<S extends string> = RestParams<S> & StandardParams<S>;
|
21 | export declare function definePage<T extends ComponentType<any> | keyof JSX.IntrinsicElements, Path extends string, P extends PathParams<Path>>(Component: T, page?: {
|
22 | path?: Path;
|
23 | getStaticPaths?: () => Promise<{
|
24 | paths: StaticPath<P>[];
|
25 | }>;
|
26 | getStaticProps?: (ctx: StaticPropsContext<P>) => Promise<{
|
27 | props: ComponentProps<T>;
|
28 | }>;
|
29 | }): {
|
30 | path?: Path;
|
31 | getStaticPaths?: () => Promise<{
|
32 | paths: StaticPath<P>[];
|
33 | }>;
|
34 | getStaticProps?: (ctx: StaticPropsContext<P>) => Promise<{
|
35 | props: ComponentProps<T>;
|
36 | }>;
|
37 | Component: T;
|
38 | };
|
39 | export {};
|