Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants