Metadata-Version: 2.4
Name: wagtailmenupage
Version: 1.2.0
Summary: A Wagtail page model for creating menu pages.
Author-email: Jack Whitworth <jack@jackwhitworth.com>
License-Expression: MIT
Project-URL: Source, https://github.com/jmwhitworth/wagtailmenupage
Project-URL: Changelog, https://github.com/jmwhitworth/wagtailmenupage/blob/main/changelog.md
Keywords: wagtail,menu,page,pages
Classifier: Framework :: Django
Classifier: Framework :: Wagtail
Classifier: Framework :: Wagtail :: 6
Classifier: Framework :: Wagtail :: 7
Classifier: Framework :: Wagtail :: 8
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: wagtail<9.0,>=5.0
Dynamic: license-file

# wagtailmenupage: Add custom menu items and external links with Wagtail's native menu system.

- [GitHub Repo](https://github.com/jmwhitworth/wagtailmenupage)
- [PyPI Package](https://pypi.org/project/wagtailmenupage/)

## Installation

Install the package:

```bash
# With pip
pip install wagtailmenupage

# Or Poetry
poetry add wagtailmenupage
```
(Or your prefered package manager)

Run migrations:
```bash
# Standard Python
python ./manage.py migrate

# If using Poetry
poetry run python ./manage.py migrate
```

Add to your `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
    ...
    "wagtailmenupage",
    ...
]
```

## Usage

### Creating a page

You can add a new Page type for menu items:

![Demo screenshot 1](assets/add-page.webp)


The 'Page' itself is very stripped down. It supports only 3 fields:

![Demo screenshot 2](assets/set-page.webp)

### Setting up the template

You can then build a menu using Wagail's built-in system, but these page items will show the correct label and URL:

```django
{% load wagtailcore_tags menupage_tags  %}
{% get_site_root as site_root %}

<nav role="navigation" aria-label="Main navigation">
    <ul>
        {% for menu_item in site_root.get_children.live.in_menu.specific %}
            <li>
                <a
                    href="{% pageurl menu_item %}"
                    {% if request.path == menu_item.url %}aria-current="page"{% endif %}
                    {% if menu_item.open_in_new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}
                >{{ menu_item.title }}</a>
            </li>
        {% endfor %}
    </ul>
</nav>
```

The above example doesn't show multi-level menus, but that can be done in the regular Wagtail way.

Take note of the logic for opening in a new tab, which is specifically required for this package's open in new tab functionality to work.

You can then re-order your menu items like normal.

For more guidance on using Wagtail menus, please [refer to their documentation](https://docs.wagtail.org/en/stable/tutorial/set_up_site_menu.html)

## Notes

These pages are excluded from the site search, don't use previews, and are excluded from sitemaps generated by the wagtail-seo package.
