UNPKG

rehype-infer-reading-time-meta

Version:

rehype plugin to infer reading time as file metadata from the document

35 lines (34 loc) 1.33 kB
/** * Infer the estimated reading time from a document as file metadata. * * The reading time is inferred not just on words per minute, but also takes * readability into account. * The result is stored on `file.data.meta.readingTime`. * * @param {Readonly<Options> | null | undefined} [options] * Configuration (optional). * @returns * Transform. */ export default function rehypeInferReadingTimeMeta(options?: Readonly<Options> | null | undefined): (tree: Root, file: VFile) => undefined; export type Root = import('hast').Root; export type VFile = import('vfile').VFile; /** * Configuration. */ export type Options = { /** * Target age group (default: `[16, 18]`); this is the age your target * audience was still in school; so, set it to `18` if you expect all readers * to have finished high school, `21` if you expect your readers to be * college graduates, etc; can be two numbers in an array to get two * estimates. */ age?: [number, number] | [number] | number | null | undefined; /** * CSS selector to body of content (optional, example: `'main'`); useful to * exclude other things, such as the head, ads, styles, scripts, and other * random stuff, by focussing all strategies in one element. */ mainSelector?: string | null | undefined; };