Settings pages
/admin/settings is a section with tabs. A layer adds a tab with a settingsPages entry and a page file.
The tabs
app/pages/admin/settings.vue is the parent route. It shows the title, the tabs, a no-permission alert, and <NuxtPage />.
General is the first tab. It shows a language card and every registered settingsPanels entry. A settings driver stores the values.
The tabs show only when 2 or more pages are visible.
Add a tab
Add a tab in two steps.
- Make a page file at
app/pages/admin/settings/<x>.vue. This is the route. - Register a
settingsPagesentry:
definePlutoExtension({
id: 'my-layer',
settingsPages: [
{
id: 'reports',
order: 30,
label: 'my-layer.settings.reports',
icon: 'lucide:chart-bar',
to: '/admin/settings/reports',
capability: 'reports:read'
}
]
})
| Field | Purpose |
|---|---|
label | A key or a literal. |
icon | Optional. |
to | The route of the page. |
capability | The capability that the user needs to see the tab. '*' means admin only. With no capability, every user in the admin sees the tab. |
Core registers two pages: general with order 0, and email with order 200. The email page is for administrators only (capability: '*'). See Mail.
The page does not repeat the title. Core renders it.
Check the capability on the server
The tab check is a UI convenience. The routes of your page must do their own server-side check.
What else changes
- The sidebar Settings item gets one child for each visible page, when there are 2 or more pages.
- The command palette lists the pages in its "Go to" group. General shows once, as "Settings".
usePlutoSettingsPages()
| Value | Meaning |
|---|---|
all | Every enabled page |
items | The pages that the user may see, sorted by order |
current | The page of the current route, by the longest to prefix |
allowed | false when the current page needs a capability that the user lacks |
When allowed is false, the parent page shows a no-permission alert and not the child.
Settings panels
A settingsPanels entry adds a form to the General tab. Register its component with defineAsyncComponent. The values go to the registered settings driver. A layer should namespace its setting keys, for example blog.posts_per_page, so that two layers never collide.
Mail panels
A mailPanels entry adds a section to the Email settings page. See Mail.