-
Notifications
You must be signed in to change notification settings - Fork 7
Auto-generate routes for components #7
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
base: main
Are you sure you want to change the base?
Conversation
@@ -8,7 +8,7 @@ export const useDynamicImport = (name: string): Props => { | |||
let resolved = false; | |||
|
|||
import(`@docgen/${name}.json`) | |||
.then(props => { | |||
.then(({ props }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was easier to update the component's createData
with the whole metadata, not only the props.
): Plugin<ComponentDoc[]> { | ||
const { generatedFilesDir } = context; | ||
|
||
const pluginId = id ?? DEFAULT_PLUGIN_ID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired by docusaurus-plugin-openapi setup.
content.map(async component => { | ||
const componentData = await createData( | ||
`${component.displayName}.json`, | ||
JSON.stringify(component) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only breaking change: component
instead of component.props
@atomicpages, could you help me on how to proceed with |
Hello there! I saw this MR and it's exactly what I need to document an SDK that my team is working on. Are there any plans on merging this one? |
cc @atomicpages |
👋 howdy, I'll dig into this more later in the week |
I think this PR deserve a merge 👍 |
Usually not keen to throw a "+1" on here but would like to bump this since it'd be super helpful for a project we're on. If timing doesn't make sense for you, @atomicpages, I can certainly fork and use my own branch. Appreciate the work here making my life a bit easier! |
Fixes #5.
I set an
addRoute
to create a route for each component, plus an index route.These routes are wrapped by some layout components:
The user can enable this behavior with a
createRoutes
flag, and also set abaseRoute
route, in which the routes/links will be created.