Skip to content

Excerpt type definition seems wrong #125

Open
@wkirby

Description

@wkirby

The type for excerpt is declared as:

type Input = string | Buffer

interface GrayMatterOption<
    I extends Input,
    O extends GrayMatterOption<I, O>
  > {
    parser?: () => void
    eval?: boolean
    excerpt?: boolean | ((input: I, options: O) => string)
    excerpt_separator?: string
    engines?: {
      [index: string]:
        | ((input: string) => object)
        | { parse: (input: string) => object; stringify?: (data: object) => string }
    }
    language?: string
    delimiters?: string | [string, string]
  }

But the example function usage in the README is:

function firstFourLines(file, options) {
  file.excerpt = file.content.split('\n').slice(0, 4).join(' ');
}

This example function does not take a string or a Buffer — it takes a GrayMatterFile and doesn't appear to return anything.

The type, I think, should be redeclared as:

excerpt?: boolean | ((file: GrayMatterFile, options: O) => void)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions