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

fix(markdown): allow plugin with array type option #2114

Merged
merged 5 commits into from Jul 18, 2023
Merged

fix(markdown): allow plugin with array type option #2114

merged 5 commits into from Jul 18, 2023

Conversation

maximepvrt
Copy link
Contributor

@maximepvrt maximepvrt commented Jun 20, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The current implementation of the markdown plugins 'rehype' and 'remark' transforme the option array into object. When providing an array, such as [{selector: 'ol', wrapper: 'p' }, {selector: 'ul', wrapper: 'p' }], it is transformed into an object with numeric keys instead of maintaining the original array structure.

content: {
        markdown: {
            rehypePlugins: {
                'rehype-wrap-all': [{selector: 'ol', wrapper: 'p' }, {selector: 'ul', wrapper: 'p' }]
            }
        }
    },

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Jun 20, 2023

βœ… Deploy Preview for nuxt-content canceled.

Name Link
πŸ”¨ Latest commit 1f8a289
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/64b652851da5440008362d86

@Atinux Atinux requested a review from farnabaz June 26, 2023 13:21
Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @maximepvrt
Do you mind adding a simple test for it?

src/runtime/markdown-parser/content.ts Outdated Show resolved Hide resolved
Co-authored-by: Farnabaz <farnabaz@gmail.com>
@maximepvrt
Copy link
Contributor Author

@farnabaz What test would you like me to add? Adding a plugin with a configuration of type 'array' in this file: https://github.com/nuxt/content/blob/main/test/fixtures/basic/nuxt.config.ts ? (for example rehype-wrap-all ?)

@farnabaz
Copy link
Member

Yes usingrehype-wrap-all would be fine.
If adding rehype-wrap-all in nuxt.config breaks other tests, feel free to duplicate fixtures/basic/server/api/parse.ts and add plugin directly there, and use new API for the test

@maximepvrt
Copy link
Contributor Author

@farnabaz Ready to merge. Looks good to me. πŸš€

@maximepvrt maximepvrt requested a review from farnabaz July 11, 2023 11:08
Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

Thanks ❀️

@farnabaz farnabaz merged commit 8469ecd into nuxt:main Jul 18, 2023
7 checks passed
@farnabaz farnabaz mentioned this pull request Jul 18, 2023
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

2 participants