Skip to content

Comments

Place Introduction subsection under main Introduction page#32

Open
HebeHH wants to merge 2 commits intohrishioa:masterfrom
HebeHH:fix-introduction-fitting
Open

Place Introduction subsection under main Introduction page#32
HebeHH wants to merge 2 commits intohrishioa:masterfrom
HebeHH:fix-introduction-fitting

Conversation

@HebeHH
Copy link
Collaborator

@HebeHH HebeHH commented May 10, 2024

The Problem

Currently there is a pretty common issue where sub-sections generated under the introduction are not attached to it in the sidebar:
image

Ideally these would be placed under the heading correctly like so:
image

Why it happens

This is because the introduction main section is called index.mdx and then the introduction sub-sections are in a folder called introduction/:
image

In order for next to display it properly, the folder name has to be the same as the main mdx file:
image
If the folder structure were like this, it would work.

Current fix

I've just added in a pretty basic check for anything with 'introduction' as the permalink, and then replaces it with index.

Proper fix

However I think you can fix this properly in page-generator.ts, where it seems like you've already got a monkeypatch fix?

I see the TODO:

    if (!metaJSON[permalink]) {
      // TODO: Need this damn monkeypatch because Nextra doesn't
      // seem to support nested pages at the top level
      metaJSON[permalink] = page.section.title;

And I think the answer is "Nextra does support nested pages at the top level, you just need to call the containing folder index. At least it works for me (see above). I think my monkeypatch will also somewhat work, but only if the toplevel folder is an introduction.

@hrishioa
Copy link
Owner

@HebeHH This might be a good idea - but this monkeypatch (so named because it relies on the model to call the intro section 'introduction' :)) might conflict with my monkeypatch. Have you tested a full generation on it? I recommend you make this a PR to your folder PR, and then test both on a full set of code for functionality, and we can merge.

@hrishioa
Copy link
Owner

@HebeHH can you test a full generation on a clean directory? If this works I'd love to merge it!

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.

2 participants