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

Support for loading custom Markdown files #193

Merged
merged 26 commits into from
Sep 2, 2022

Conversation

danieleds
Copy link
Contributor

@danieleds danieleds commented Jul 11, 2022

This PR adds the following features:

  • support for loading arbitrary markdown files from the file system tree
  • support for _spec_.{yaml,yml,json} files, which do not generate a new category
  • support for sorting categories and items in the sidebar using _category_ or front matter in custom mdx files

Solves:

Example

File tree (notice examples/custom-overview.md, examples/petstore/_spec_.yaml, examples/petstore/my-intro.md):

Screenshot 2022-07-11 at 18 21 35

Results:

Screenshot 2022-07-11 at 18 20 45

Screenshot 2022-07-11 at 18 20 52


@bourdakos1 I would love your review on this.

There are a lot of changes in the diff, but most of the stuff (the one in packages/docusaurus-plugin-openapi/src/docs/) has been taken and "tree-shaked" from the original plugin-content-docs plugin (they don't export those functions, unfortunately).

@netlify
Copy link

netlify bot commented Jul 11, 2022

Deploy Preview for docusaurus-openapi ready!

Name Link
🔨 Latest commit 4c1ab36
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-openapi/deploys/62e8e536d04ee8000800ada0
😎 Deploy Preview https://deploy-preview-193--docusaurus-openapi.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bourdakos1
Copy link
Member

Is this ready for review?

@danieleds
Copy link
Contributor Author

@bourdakos1 It is ready, I am just making some minor linting fixes

@bourdakos1
Copy link
Member

It will probably take me a few days to review this, but I’m excited for the update 😁

packages/docusaurus-plugin-openapi/src/docs/docs.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,223 @@
/* ============================================================================
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to keep the original license headers. You may need to update eslint to allow different headers for these files. I think we also need to update this project’s license to include the original copy from Docusaurus’ license

Copy link
Member

Choose a reason for hiding this comment

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

It may also be worth reaching out to Docusaurus and ask if they could expose all this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bourdakos1 It's a bit complicated because I had to remove all the logic that had to do with versions, which we don't support. So they would have to do some large changes to be able to export this in a way that is generic enough for us.

For now, I clarified that these files are taken and adapted from upstream. I also updated the license headers.

@danieleds
Copy link
Contributor Author

fixed a bug where the slug property wasn't properly recognized

@bourdakos1
Copy link
Member

The "My Custom Petstore" / "My Intro" page doesn't load for me

@danieleds
Copy link
Contributor Author

My bad, I forgot to push stuff. Could you try it again?

Copy link
Member

@bourdakos1 bourdakos1 left a comment

Choose a reason for hiding this comment

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

Excellent work! Sorry it took so long to review, this was just a big change and I wanted to be thorough. I think this will have one small issue where the custom markdown pages won’t be seen by the “next”/“previous” page buttons. However, we can look into fixing that later.

Thanks again, I really appreciate all the work you’ve put into this ❤️❤️❤️

@bourdakos1 bourdakos1 merged commit 11a5067 into cloud-annotations:main Sep 2, 2022
@joanjane
Copy link

Great feature! Do you have plans to release a new version of the package on npm? I'm interested using this feature too :)

Thank you!

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.

None yet

3 participants