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(content): use property-information to convert hast attributes #359

Merged
merged 3 commits into from
Aug 6, 2020

Conversation

benjamincanac
Copy link
Member

@benjamincanac benjamincanac commented Aug 6, 2020

Fix props rendering in nuxt-content component.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

The issue is in the nuxt-content component when rendering the AST tree with Vue.js, specific prop needed to stay in camelCase when others needed to be transformed back to kebab-case.

To fix #139, we forced camelCase props to kebab-case to ensure ariaHidden was rendered as aria-hidden. But then with #309, <video autoplay ...> was transformed to { autoPlay: true } in the tree (HAST spec, see also property-information code) and then rendered to auto-play because of the module forcing kebab-case.

To transform markdown to AST, we use remark and rehype, to handle embedded HTML we use rehype-raw which under the hood use property-information that allows to convert HAST properties.

This PR takes advantage of the property-information package to render props as their original html name. It adds 30kb inside the client package but I feel like we don't have a choice here.

Screenshot 2020-08-06 at 12 24 52

Copy link
Member

@atinux atinux left a comment

Choose a reason for hiding this comment

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

Looking good, only tests are needed to ensure no regression in the future.

Nice work and great description 🙌

@benjamincanac benjamincanac merged commit 58061e0 into dev Aug 6, 2020
@benjamincanac benjamincanac deleted the fix/props-rendering branch August 6, 2020 14:02
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.

Can't use autoplay attribute in video tag in Markdown Anchor link has aria-hidden is not output correctly
2 participants