The excerpt function option should be a function that returns a string, but it isn't #170
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
excerptfield to its first argument like so: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.
I have been at it since hours and still couldn't fix it. I believe the signature for the
excerptfunction is incorrect. It should be something likeShould I make a PR?
@DarhkVoyd That would likely be the best change to make that's consistent with the real function signature. However there are a couple of flaws with the real function signature:
excerpt(optional field) to be a union of:boolean— iftrue, the default "extract excerpt" implementation would be usedstring— overrides default "extract excerpt" implementationstring— for backwards compatibility (until a major version is released) since the current implementation interprets astringexcerptlikeexcerpt_separatorGrayMatterFileis confusing since it implies some strong correlation with a file-system object but there is no correlation to speak of. It's really just an ad hoc global state dictionary being passed around between functions. And most of its fields aren't even necessary for findingexcerpt.input(i.e. the first argument of theexcerptfunction type) should probably be something like astringorBuffer. (This would be a backwards incompatible change which should only be made on a major release).To be clear, the existing TypeScript annotations are fine on their own; it's the implementation that needs to match.
Probably not. Despite numerous issues and PRs, there hasn't been a significant change to this repository in over 5 years, so you'd probably be wasting your time. I don't blame the author since lack of monetizability in open source is a serious issue and they probably have better things to do with their time.
Here's a (relatively) sane wrapper for
graymattertaken straight from the source code for my website:How about if I just ignore that one line causing the whole lot this trouble.
They're both band-aids over a gaping wound. If that's the band-aid you prefer, then that's fine. As long as you can remember that the TypeScript function signature is a lie.