Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docz): allow for custom properties in useMenus hook #1246

Merged
merged 2 commits into from
Nov 11, 2019
Merged

feat(docz): allow for custom properties in useMenus hook #1246

merged 2 commits into from
Nov 11, 2019

Conversation

NicolaiF
Copy link
Contributor

@NicolaiF NicolaiF commented Nov 11, 2019

Description

Adding the feature of accessing custom properties from mdx-files in the useMenus hook.
As a side-effect of this, other preexisting fields such as slug and headings, are also included in the hook. This could potentially be improved by filtering these out, and only allowing for the original properties found in useMenus previously.

Pre-merge checklist

  • Check that all example projects are working.


const entriesOfMenu = (menu: string, entries: Entry[]) =>
entries.filter(fromMenu(menu)).map(entryAsMenu)
entries.filter(fromMenu(menu)).map(e => e as any) as MenuItem[]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we remove the map since we're passing to it an identity function ?

@rakannimer
Copy link
Contributor

Hey @NicolaiF

Thanks for the PR, looks great !

The tests will make sure to test the code against the examples so you shouldn't need to 👍

I added one small comment, that applies to both uses of .map with an identity function (e => e).

Let me know what you think before we merge and publish.

@NicolaiF
Copy link
Contributor Author

Needed to update the types a couple of places to make it work without map, but it looks like everything works fine now!

@rakannimer
Copy link
Contributor

Awesome ! Thanks :)

@rakannimer rakannimer changed the title feat: allowing for custom properties in hook useMenus feat(docz): allow for custom properties in useMenus hook Nov 11, 2019
@rakannimer rakannimer merged commit 20df733 into doczjs:master Nov 11, 2019
@rakannimer
Copy link
Contributor

Fixes #1238 (for future reference)

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