Items in the main navigation bar can be direct links, or dropdowns with subitems. This context preprocessor adds a boolean field ``has_subitems`` that tells which one of them every element is. It also adds a ``slug`` field to be used as a CSS id.
(context)
| 76 | |
| 77 | @staticmethod |
| 78 | def navbar_add_info(context): |
| 79 | """ |
| 80 | Items in the main navigation bar can be direct links, or dropdowns with |
| 81 | subitems. This context preprocessor adds a boolean field |
| 82 | ``has_subitems`` that tells which one of them every element is. It |
| 83 | also adds a ``slug`` field to be used as a CSS id. |
| 84 | """ |
| 85 | for i, item in enumerate(context["navbar"]): |
| 86 | context["navbar"][i] = dict( |
| 87 | item, |
| 88 | has_subitems=isinstance(item["target"], list), |
| 89 | slug=(item["name"].replace(" ", "-").lower()), |
| 90 | ) |
| 91 | return context |
| 92 | |
| 93 | @staticmethod |
| 94 | def blog_add_posts(context): |