- typed client and useMenu/useMenuApi (SSR, menu:<code>:<locale> key, server and public bases, x-forwarded-for forwarded also on cached renders) - MenuNav and recursive MenuNavItem: WAI disclosure navigation, URL allowlist with a text fallback, rel on _blank, active link and trail, mobile toggle, Esc / focus-out / outside pointer / route change closing - menu tokens and base CSS, README - node tests (link rules, client, server-rendered NavItem) and a playground SSR smoke against a fixture API
29 lines
732 B
TypeScript
29 lines
732 B
TypeScript
// The response shape of GET /_menu/api/v1/menus/{code}?locale=xx (the menu
|
|
// plugin's public API). Generated children of a list type carry id null and
|
|
// the parent's registry type.
|
|
|
|
export interface MenuEntry {
|
|
id: number | null
|
|
title: string
|
|
/** "url", "divider" or a registry type key such as "all-journal-categories". */
|
|
type: string
|
|
/** Null for dividers and for a URL the server refused (scheme allowlist). */
|
|
url: string | null
|
|
target: '_self' | '_blank' | null
|
|
css_class: string | null
|
|
icon: string | null
|
|
code: string | null
|
|
items: MenuEntry[]
|
|
}
|
|
|
|
export interface Menu {
|
|
code: string
|
|
name: string
|
|
css_class: string | null
|
|
items: MenuEntry[]
|
|
}
|
|
|
|
export interface MenuEnvelope {
|
|
data: Menu
|
|
}
|