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

Better support for dynamic pages #4208

Open
MOZGIII opened this issue Feb 13, 2025 · 3 comments
Open

Better support for dynamic pages #4208

MOZGIII opened this issue Feb 13, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@MOZGIII
Copy link

MOZGIII commented Feb 13, 2025

Today, Nextra fails you miserably when you try using generateStaticParams for something like templated table-driven doc pages.

In particular, when trying to generate the items in _meta.ts file dynamically for the values from generateStaticParams, the Nextra meta validation code fails being unable to find a file that would correspond to the route path - and no shit, it's covered by a dynamic [id]/page.ts route and generateStaticParams.

So, what can we do? I propose to add a flag to _meta file for creating virtual file-like entries. The workaround we use for now is href - but that sucks cause those entries don't show up as real routes and don't get highlighting the real routes would have.

@MOZGIII MOZGIII added the enhancement New feature or request label Feb 13, 2025
@dimaMachina
Copy link
Collaborator

You need to manually enhance page map while using dynamic routes https://nextra.site/docs/advanced/remote#enhance-pagemap

@MOZGIII
Copy link
Author

MOZGIII commented Feb 13, 2025

That's what I'm doing. The issue is there types that Nextra provides are rudimentary, and the machinery for that is virtually non-existent.

The use case that is covered by the docs, and, seems like, by the support machinery, is remote content. Which is not what I'm doing.

The docs showcase an example where the data is appended to the end of the list - well, that's easy, yes.
However, extending a deeply nested folder with the dynamic children is very inconvenient, and if this is the way to go there should be a much better suite of tools - types and utility functions - to help with this.


Ultimately, l still want to control placement of the folder though _meta files, to avoid writing the procedural placement logic insertion / merging code. So, what I'm doing for now is I have a myFolder: { type: "separator" }, and then I just replace it programmatically in page map in both actual page item and the the data item. I replace it with a folder with programmatically populated children; then normalize - and it works.

Would be much better if there was a type: "virtual" entry at metadata with a customData: any, and a helper that would allow you to find all such type: "virtual" nodes and provide a replacement for them.

@MOZGIII
Copy link
Author

MOZGIII commented Feb 13, 2025

Oh, actually, see humanode-network/biomapper-docs#50 for a concrete example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants