Core

Settings pages

Add a tab to the Settings section of the admin.

/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.

  1. Make a page file at app/pages/admin/settings/<x>.vue. This is the route.
  2. Register a settingsPages entry:
app/plugins/pluto-extension.ts
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'
    }
  ]
})
FieldPurpose
labelA key or a literal.
iconOptional.
toThe route of the page.
capabilityThe 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()

ValueMeaning
allEvery enabled page
itemsThe pages that the user may see, sorted by order
currentThe page of the current route, by the longest to prefix
allowedfalse 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.