import { Metadata } from ".";
declare namespace generateHTML {
/**
* Represents an HTML tag and associated HTML attributes.
* @template AddedAttributes User-provided attributes for the tag.
*/
interface ImgAttributes {
img: AddedAttributes & {
src: string;
width: number;
height: number;
srcset?: string;
sizes?: string;
};
}
/**
* Represents a HTML tag and associated HTML attributes.
*/
interface SourceAttributes {
source: {
type: string;
srcset: string;
sizes?: string;
};
}
/**
* Represets a HTML tag and its child elements.
* @template AddedAttributes User-provided attributes for the tag.
*/
interface PictureAttributes {
picture: [...SourceAttributes[], ImgAttributes];
}
/**
* Returns objects representing HTML tags for the given `metadata`.
*
* @param metadata Image metadata generated by `Image()`.
* @param attributes Attributes for the tag.
* Must include `alt` (alt="" works okay).
* Must include `sizes` when using multiple source widths.
*/
function generateObject(
metadata: Metadata,
attributes?: AddedAttributes,
): ImgAttributes | PictureAttributes;
interface GenerateHTMLOptions {
/**
* You can use the whitespaceMode option to strip the whitespace from the output of the element
* (a must-have for use in markdown files).
* @default 'block'
*/
whitespaceMode?: "inline" | "block";
}
}
/**
* Returns a HTML string for the given `metadata`.
* Will be either a or .
*
* @param metadata Image metadata generated by `Image()`.
* @param attributes Attributes for the tag.
* Must include `alt` (alt="" works okay).
* Must include `sizes` when using multiple source widths.
*/
declare function generateHTML(
metadata: Metadata,
attributes?: { alt: string } & Partial>,
options?: generateHTML.GenerateHTMLOptions,
): string;
export = generateHTML;