UNPKG

presta

Version:

Hyper minimal framework for the modern web.

51 lines (50 loc) 1.89 kB
type GenericObject = { [key: string]: any; }; export type HeadElementWithChildren<T> = { children?: string; } & T; export type Meta = Partial<Omit<HTMLMetaElement, 'children'>> | string; export type Link = Partial<Omit<HTMLLinkElement, 'children'>> | string; export type Style = Partial<HeadElementWithChildren<Omit<HTMLStyleElement, 'children'>>> | string; export type Script = Partial<HeadElementWithChildren<Omit<HTMLScriptElement, 'children'>>> | string; export type HeadElement = Meta | Link | Style | Script; type Social = { title?: string; description?: string; image?: string; url?: string; [key: string]: string | undefined; }; export type PrestaHead = { title: string; description: string; image: string; url: string; og: Social; twitter: Social; meta: Meta[]; link: Link[]; script: Script[]; style: Style[]; }; export type DocumentProperties = { body?: string; head?: Partial<PrestaHead>; foot?: Partial<Pick<PrestaHead, 'script' | 'style'>>; htmlAttributes?: Partial<{ [key in keyof HTMLHtmlElement]: string; }>; bodyAttributes?: Partial<HTMLBodyElement>; }; export declare function pruneEmpty(obj: GenericObject): GenericObject; export declare function filterUnique(arr: HeadElement[]): HeadElement[]; export declare function tag(name: string): (props: HeadElement) => string; export declare function prefixToObjects(prefix: string, props: Social): HeadElementWithChildren<Partial<HTMLMetaElement>>[]; export declare function createHeadTags(config?: Partial<PrestaHead>): string; export declare function createFootTags(config?: Partial<Pick<PrestaHead, 'script' | 'style'>>): string; /** * Generates a string representing a complete HTML document */ export declare function html({ body, head, foot, htmlAttributes, bodyAttributes, }: DocumentProperties): string; export {};