Problem/Motivation
The module currently fails to generate the correct hierarchical structure for menus in the llms.txt file.
Instead of traversing the menu tree recursively, the module seems to be rendering items sequentially by depth/weight. This results in child items being visually appended to the last parent rendered of the previous level, rather than their actual parent.
Drupal menu:

Llms.txt:

Steps to reproduce
- Create a Main Menu structure with at least two parent items.
- Add a child item to the first parent item.
- Leave the second parent item without children.
- Generate/view the
llms.txt file.
- Observe that the child of the first parent is rendered indented under the second parent.
Example scenario:
- Parent Item 1
-- Child Item A
- Parent Item 2
Current output in llms.txt:
- [Parent Item 1](url)
- [Parent Item 2](url)
- [Child Item A](url) <-- INCORRECT: It appears as a child of Parent 2
Proposed resolution
The rendering logic needs to be refactored to traverse the menu tree properly.
Comments
Comment #2
albeorte commentedComment #3
albeorte commentedComment #4
albeorte commentedComment #6
albeorte commentedThe changes have been implemented and tested.
Ready for review by the community.
Comment #7
mxr576Thanks for the issue, we will looking into it shortly. Meanwhile, could you please extend the module's test coverage to cover this issue?
Comment #8
mxr576Comment #9
mxr576Comment #11
mxr576Thanks for the contribution!
https://www.drupal.org/project/llms_txt/releases/1.0.5