UNPKG

remark-contributors

Version:

remark plugin to inject a given list of contributors into a table

58 lines (57 loc) 1.96 kB
/** * @typedef {import('mdast').PhrasingContent} PhrasingContent * @typedef {import('#get-contributors-from-package').Contributor} Contributor */ /** * @callback Format * Format a field. * @param {unknown} value * Value of a field in a contributor. * @param {string} key * Name of a field in a contributor. * @param {Contributor} contributor * Whole contributor. * @returns {Array<PhrasingContent> | PhrasingContent | string | null | undefined} * Content. * * @typedef FormatterObject * How to format a field. * @property {boolean | null | undefined} [exclude=false] * Whether to ignore these fields (default: `false`). * @property {Format | null | undefined} [format] * How to format the cell (optional). * @property {string | null | undefined} [label] * Text in the header row that labels the column for this field (optional). * * @typedef {Record<string, FormatterObject>} FormatterObjects * Map of fields found in `contributors` to formatter objects. */ /** @type {FormatterObjects} */ export const defaultFormatters: FormatterObjects; export type PhrasingContent = import('mdast').PhrasingContent; export type Contributor = import('#get-contributors-from-package').Contributor; /** * Format a field. */ export type Format = (value: unknown, key: string, contributor: Contributor) => Array<PhrasingContent> | PhrasingContent | string | null | undefined; /** * How to format a field. */ export type FormatterObject = { /** * Whether to ignore these fields (default: `false`). */ exclude?: boolean | null | undefined; /** * How to format the cell (optional). */ format?: Format | null | undefined; /** * Text in the header row that labels the column for this field (optional). */ label?: string | null | undefined; }; /** * Map of fields found in `contributors` to formatter objects. */ export type FormatterObjects = Record<string, FormatterObject>;