Completed Edit me
A user can nest pages to any level of depth

User Story

As a PRACTICAL ™ Documentation System User, I want to be able to nest pages as many levels as necessary to properly “chop up” the Epic to digestible user stories. This means, I should be allowed to nest pages to potentially infinite depth.

Acceptance Criteria

  1. Scenario 1

    • Given that I have some pages “A.html”, “B.html”, “C.html”, “D.html” etc.

      and both files exist in the “my_product” folder under “pages”

    • I can use the “folderitems” element in the the sidebar yaml file as many times as needed to nest as deeply as needed:

      - title: This is Page A
        url: /pages/my_product/A.html
        output: web, pdf
        folderitems:
        - title: This is Page B
          url: /pages/my_product/B.html
          output: web, pdf
          folderitems:
          - title: This is Page C
            url: /pages/my_product/c.html
            output: web, pdf
            folderitems:
            - title: This is Page D
              url: /pages/my_product/d.html
              output: web, pdf
              folderitems:
              - title: This is Page E
                url: /pages/my_product/e.html
                output: web, pdf
      
                etc...
      
    • Then each level that contains any folderitems will be shown as a folder in the nav bar and each level that does not contain any folderitems will be shown as a page in the nav bar and any level that has folderitmes, but does not have a URL will be treated as only a folder but any level that has both a URL and folderitems will be treated both as a link to the page and as a folder

Implementation

To implement this, I mainly edited “_includes\sidebar.html”. A number of issues needed to be resolved.

The first issues to resolve was the inability to nest more than 2 levels deep in the navigation. The sidebar.html template wasn’t set up properly for this. Here’s what I had to do:

  • Separate the subfolder processing out into it's own include file "_includes\sidebar_subfolders.html".
  • Update both templates to expect only "folders" and "folderitems" variables to be found in the sidebar.yml, rather than the "subfolders" and "subfolderitems" variables it was originally expecting.
  • Update the new sidebar_subfolders.html template to accept the folder it's currently working on as an input parameter. This allowed for infinite nesting of folders.
  • To left-offset each item in the menu, move the padding out of the CSS and into an element level style tag, then use an include parameter along with a math filter to calculate the padding at the current level of nesting.