Skip to content

Conversation

Andarist
Copy link
Member

cc @remcohaszing, maybe you'd have a sec to double-check if I'm using the most kosher tools here? 😅

Copy link

changeset-bot bot commented May 17, 2025

⚠️ No Changeset found

Latest commit: 990d677

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@remcohaszing remcohaszing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some tips, but really the tools you’re currently using are fine as-is too. :)


export function getChangelogEntry(changelog: string, version: string) {
let ast = unified().use(remarkParse).parse(changelog) as Root;
let ast = unified().use(remarkParse).parse(changelog);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you support GFM and/or frontmatter here? Is so, you should use remark-gfm / remark-frontmatter.

Unless you need options passed into the function, I recommend to define the processor once outside of the function. This way plugins can cache some of the heavy lifting. This isn’t really applicable to your case, but IMO it’s a good practice. If you use GFM/frontmatter, this also allows you to keep the processor in sync with the stringify processor you use below.

const processor = unified()
  .use(remarkParse)
  .use(remarkFrontmatter)
  .use(remarkGfm)
  .use(remarkStringify)

// …

let ast = processor.parse(changelog)

If you don’t want any of that, the remark abstractions don’t really offer much. You might as well use the slightly lower level mdast-util-from-markdown and mdast-util-to-markdown.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants