Skip to content

Commit 306e7c6

Browse files
committed
Add docs for headless user bar setup
1 parent c0aa174 commit 306e7c6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

headless-userbar.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Exposing the Wagtail user bar to the headless frontend
2+
3+
This document explains how the Wagtail userbar is made available to frontend applications in a headless setup, including the use of the custom `UserbarView`, URL configuration, and customization of the accessibility item for cross-origin support.
4+
5+
## 1. UserbarView and URL Configuration
6+
7+
A custom Django view, `UserbarView`, is implemented in `bakerydemo/headless.py` to expose the Wagtail userbar as an API endpoint. The example in this repo does not handle authentication; it only renders the userbar and sets the necessary CORS header. This may need to be adjusted depending on how the API is accessed by the frontend.
8+
9+
To make the userbar accessible to the frontend, a URL pattern for the `UserbarView` is added in the main `urls.py`. This exposes the userbar at `/userbar/`, which the frontend can call to retrieve the userbar markup or data.
10+
11+
## 2. Customizing the AccessibilityItem for Cross-Origin Support
12+
13+
The `allowedOrigins` property in Axe's spec must be set to the headless frontend's host. This allows Axe in the page editor to securely communicate with the frontend for accessibility checks. This can be done by overriding `get_axe_spec` in an `AccessibilityItem` subclass. The subclass is then used via the `construct_wagtail_userbar` hook.
14+
15+
## References
16+
17+
- [`bakerydemo/headless.py`](./bakerydemo/headless.py): Contains the `UserbarView` implementation.
18+
- [`bakerydemo/urls.py`](./bakerydemo/urls.py): Main URL configuration including the userbar endpoint.
19+
- [`bakerydemo/base/wagtail_hooks.py`](./bakerydemo/base/wagtail_hooks.py): Customizes the accessibility item for cross-origin support.

0 commit comments

Comments
 (0)