Dioxus: Compile Time Page Generation using Procedural Macros

Hello everyone :wave:
For a hobby project I'm using Dioxus and would like to be able to generate pages at compile time based on files in a specific directory.
To achieve this, I decided to try writing procedural macros for the first time in my rust learning process.
Unfortunately, the generated pages don't work properly and I get error messages in my browser like "index out of bounds: the len is 0 but the index is 0" or "already borrowed: BorrowMutError".
Also, I have no idea how to debug the webassembly properly and if I simply replace the macro call with the expanded macro, it just works.
Any help, advice, hints, etc. would be greatly appreciated (including general improvements that don't necessarily solve the problem at hand).
Thank you very much :slightly_smiling_face:

The result of my efforts can be seen here: GitHub - LeWimbes/dioxus-page-generation

Interestingly, at least the page generation works with dioxus 0.6.0-alpha.1, although the routes still have to be written by hand.

You can find the code on an extra branch: GitHub - LeWimbes/dioxus-page-generation at using-0.6.0

Evan Almloff, one of the developers of dioxus, replied to me on their Discord server.
The problem is that the template IDs are currently not unique when using nested macros. They will fix this by the full release of 0.6.0. Until then, feel free to use my dirty solution at GitHub - LeWimbes/dioxus at fix-colliding-template-ids.

1 Like