feat: MenuNav layer for the SummerCMS menu API
- 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
This commit is contained in:
28
app/utils/types.ts
Normal file
28
app/utils/types.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user