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

Headings for Children of Components do not work #3749

Open
nikischin opened this issue Nov 29, 2024 · 8 comments
Open

Headings for Children of Components do not work #3749

nikischin opened this issue Nov 29, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@nikischin
Copy link
Contributor

nikischin commented Nov 29, 2024

Describe the bug

Headings for children of imported documents do not work as expected. They behave very strange.

To Reproduce

sample.mdx

import Template from "./template.mdx";

<Template someProp="someValue">
    ## Subheading from Child should be inbetween second and third heading

    Some Text from child
</Template>

template.mdx

# Title of Imported file

Someprop has {props.someProp}

## First Heading of Imported file

Some Text of Imported file

## Second Heading of Imported file

Some Text of Imported file

Children is below this

{props.children}

## Third Heading of Imported file

Some Text of Imported file

## Fourth Heading of Imported file

Some Text of Imported file

Expected behavior

Children with heading should be inbetween other headings of parent imported file.

Screenshots
Bildschirmfoto 2024-11-29 um 18 15 42

Desktop:

  • OS: macOS
  • Browser Safari
  • Version 18.1.1
@nikischin nikischin added the bug Something isn't working label Nov 29, 2024
@nikischin
Copy link
Contributor Author

Also it will crash if props are used within headings:

## Someheading containing {props.someProp}

Will produce an error like this:

Cannot read properties of undefined (reading 'props.someProp')
...
export function useTOC(props) {
  13 |   return [{
> 14 |     value: <>{"Someheading containing "}{props.someProp}</>,

Should I open a separate ticket for this?

@nikischin
Copy link
Contributor Author

Generally headings in combination with embedded documents do not work well.

Even if I use something like

import TemplateWithoutChild from "./template.mdx";

<TemplateWithoutChild />

## Some other Heading outside template
This is displayed correctly in the sidebar but the heading is not displayed correctly in the content (The first heading of the Template is displayed instead here which should not be the case.

This does work for the sidebar but not the content itself.

@dimaMachina
Copy link
Collaborator

Describe the bug

Headings for children of imported documents do not work as expected. They behave very strange.

To Reproduce

sample.mdx

import Template from "./template.mdx";

<Template someProp="someValue">
    ## Subheading from Child should be inbetween second and third heading

    Some Text from child
</Template>

template.mdx

# Title of Imported file

Someprop has {props.someProp}

## First Heading of Imported file

Some Text of Imported file

## Second Heading of Imported file

Some Text of Imported file

Children is below this

{props.children}

## Third Heading of Imported file

Some Text of Imported file

## Fourth Heading of Imported file

Some Text of Imported file

Expected behavior

Children with heading should be inbetween other headings of parent imported file.

Screenshots Bildschirmfoto 2024-11-29 um 18 15 42

Desktop:

  • OS: macOS
  • Browser Safari
  • Version 18.1.1

I think this hidden bug was fixed in Nextra 4 in https://github.com/shuding/nextra/pull/3698/files
image

@nikischin
Copy link
Contributor Author

Hi @dimaMachina, thank you so much for your investigation and answer!

I totally understand your focus already is on v4, and I also followed your other threads on it. However I wasn't able to find the blog post for migration you were talking about, so I haven't yet started migration. Would you have a link for me to the blog post maybe? I would be happy to try the new version soon!

@dimaMachina
Copy link
Collaborator

Did’t yet post, I am on vacation and there is some new missing features to document

@nikischin
Copy link
Contributor Author

Did’t yet post, I am on vacation and there is some new missing features to document

Ah no worries! Enjoy your vacation and happy to see some update after you are back. Thank you so much for still checking Github issues during vacation!

@nikischin
Copy link
Contributor Author

@dimaMachina

I think this hidden bug was fixed in Nextra 4 in https://github.com/shuding/nextra/pull/3698/files

image

Unfortunately this bug still persists in v4.

@dimaMachina
Copy link
Collaborator

Hi, feel free to share a reproduction, so it could be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants