Metadata-Version: 2.4
Name: wagtailmenupage
Version: 1.0.1
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: 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<8.0,>=5.0
Dynamic: license-file

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

- [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

You can add a new Page type for menu items:

![Demo screenshot 1](https://github.com/jmwhitworth/wagtailmenupage/blob/main/assets/readme_1.jpg)


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

![Demo screenshot 2](https://github.com/jmwhitworth/wagtailmenupage/blob/main/assets/readme_2.jpg)


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>
        <li>
            <a
                href="{% pageurl site_root %}"
                {% if request.path == site_root.url %}aria-current="page"{% endif %}
            >Home</a>
        </li>
        {% for menuitem in site_root.get_children.live.in_menu.specific %}
        
            <li>
                <a
                    href="{% pageurl menuitem %}"
                    {% if request.path == menuitem.url %}aria-current="page"{% endif %}
                    {% if menuitem.open_in_new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}
                >{{ menuitem.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.
