slidevjs / slidev

Presentation Slides for Developers
https://sli.dev
MIT License
32.82k stars 1.33k forks source link

Slide attribute "frontmatter" is always "[object Object]" #1794

Closed benweidig closed 2 months ago

benweidig commented 2 months ago

Describe the bug

Each div.slidev-layout has an attribute frontmatter that's always [object Object]

Minimal reproduction

Steps to reproduce the behavior:

  1. npm init slidev@latest
  2. Fill out the necessary things to create and start the project
  3. Check HTML

Environment

Selection_018

KermanX commented 2 months ago

Thank you for mentioning this. This is because currently, we can't find a way to detect whether the layout component receives a frontmatter property. As a workaround, all frontmatters excluding the known ones and frontmatter for the frontmatter object are passed to props. If the layout component doesn't have the corresponding props, these "extra" props will become DOM attributes.

Ref: #1303 #1312

antfu commented 2 months ago

That's how Vue works - do you have any runtime problems because of that? Otherwise I'd say just ignore it, it doesn't matter after all

benweidig commented 2 months ago

It doesn't cause me any runtime problems. So far, it's smooth sailing and the best and easiest-to-use slide tool for my purposes!

Just noticed the [object Object], and without any Vue knowledge, it looked like an oversight/possible issue. However, I somehow missed the referenced issue/PR, even though I searched before creating this one...

Thank you for explaining it to me, as I didn't get far looking at constants.ts and InjectionKey myself.