Metadata-Version: 2.4
Name: wagtail-link-block
Version: 1.2
Summary: A Block for Wagtail that lets users choose a Page/Document/URL/email/etc. as a link
Maintainer-email: The Developer Society <studio@dev.ngo>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://github.com/developersociety/wagtail-link-block
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Wagtail :: 6
Classifier: Framework :: Wagtail :: 7
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Wagtail>=6.3
Dynamic: license-file

# Wagtail Link Block

A link block to use as part of other StructBlocks which lets the user choose a link either to a
Page, Document, external URL, Email, telephone or anchor within the current page and whether or
not they want the link to open in a new window.

It hides the unused fields, making the admin clearer and less cluttered.

## Installation

Using [pip](https://pip.pypa.io/):

```console
$ pip install wagtail-link-block
```

Edit your Django project's settings module, and add the application to ``INSTALLED_APPS``:

```python
INSTALLED_APPS = [
    # ...
    "wagtail_link_block",
    # ...
]
```

## Usage

To use in a block

```python
from wagtail_link_block.blocks import LinkBlock

class MyButton(StructBlock):
    text = CharBlock()
    link = LinkBlock()

    class Meta:
        template = "blocks/my_button_block.html"
```

And create the template `blocks/my_button_block.html`:

```html
<a href="{{ self.link.get_url }}" {% if self.link.new_window %}target="_blank" rel="noopener noreferrer"{% endif %}>
    {{ self.text }}
</a>
```
