Skip to content

Commit a6d7676

Browse files
authored
docs(menu): link_to takes a block for sub-items (#665)
1 parent 063d1b1 commit a6d7676

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

docs/4.0/menu-editor-api.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,18 @@ Also accepts the shared [`icon`](#icon), [`color`](#color), [`hotkey`](#hotkey),
9898
| `true` / `false` | Forces the state. |
9999

100100
:::warning `active` is ignored on sub-items
101-
For links nested inside a `resource` block, Avo computes the active sub-item itself — inclusively, favoring the most specific (longest) matching path — and a per-link `active:` has no effect.
101+
For links nested inside a `resource` or `link_to` block, Avo computes the active sub-item itself — inclusively, favoring the most specific (longest) matching path — and a per-link `active:` has no effect.
102102
:::
103103

104+
Passing a block nests sub-items under the link — see the [sub-items guide](./menu-editor.html#sub-items). The link itself stays clickable, and Avo forces it active while one of its children is.
105+
106+
```ruby
107+
link_to "Design", path: "/admin/design" do
108+
link_to "Chat", path: "/admin/design/chat"
109+
link_to "Loader", path: "/admin/design/loader"
110+
end
111+
```
112+
104113
</Option>
105114

106115
<Option name="`resource`" headingSize="3">

docs/4.0/menu-editor.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The `all_resources` helper takes your [authorization](./authorization) rules int
9090

9191
## Sub-items
9292

93-
You can nest items beneath a `resource` by passing a block. They appear as child items under the resource link in the sidebar. Any item type can be nested; a nested `resource`, `dashboard`, `page`, `board`, or `action` resolves its own URL automatically, so only `link_to` needs an explicit `path:`. A nested `action` also inherits its enclosing resource, so you don't repeat it.
93+
You can nest items beneath a `resource` or a `link_to` by passing a block. They appear as child items under the parent link in the sidebar, which stays clickable and goes to its own page. Any item type can be nested; a nested `resource`, `dashboard`, `page`, `board`, or `action` resolves its own URL automatically, so only `link_to` needs an explicit `path:`. A nested `action` also inherits its enclosing resource, so you don't repeat it.
9494

9595
```ruby
9696
# config/initializers/avo.rb
@@ -104,6 +104,12 @@ Avo.configure do |config|
104104
board 1 # nested kanban board
105105
action Avo::Actions::ExportData # nested action (inherits :projects)
106106
end
107+
108+
# A plain link nests the same way — a custom page and its sub-pages.
109+
link_to "Design", path: "/admin/design" do
110+
link_to "Chat", path: "/admin/design/chat"
111+
link_to "Loader", path: "/admin/design/loader"
112+
end
107113
}
108114
end
109115
```
@@ -219,7 +225,7 @@ A [collapsable](./menu-editor-api.html#collapsable) section or group already car
219225

220226
## Icons
221227

222-
The [`icon`](./menu-editor-api.html#icon) option is supported on `section` and on individual menu items (`link_to`, `resource`, `dashboard`, `page`, `form`, `board`, `action`). It is not supported on `group` or on sub-items nested inside a `resource` block.
228+
The [`icon`](./menu-editor-api.html#icon) option is supported on `section` and on individual menu items (`link_to`, `resource`, `dashboard`, `page`, `form`, `board`, `action`). It is not supported on `group` or on sub-items nested inside a `resource` or `link_to` block.
223229

224230
You can use icons from [Tabler Icons](https://tabler.io/icons) (preferred in Avo 4) or from [Heroicons](https://heroicons.com/) (both `outline` and `solid` variants).
225231

0 commit comments

Comments
 (0)