Skip to content

The excerpt function option should be a function that returns a string, but it isn't #170

Open
@loqusion

Description

The return value is not used, at all, despite what the function's type signature would have you believe. Instead, you're expected to assign the excerpt field to its first argument like so:

function firstFourLines(input: UnspecifiedObject, options: GrayMatterOption): void {
  input.excerpt = input.content.split('\n').slice(0, 4).join(' ');
}

const { data } = graymatter(file, { excerpt: firstFourLines })

This is extremely easy to miss, and had me banging my head against the wall for hours. Hopefully this will help somebody with the foresight to check the GitHub issues.

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