为导航添加子菜单。

  • 名称: core/navigation-submenu
  • 类别: 设计
  • API 版本: 3
  • 块类型: 混合(静态保存 + 服务器增强)

块关系

父级块(直接):
– core/navigation

属性

通过 block.json 中的 attributes 属性定义。

属性类型默认值描述
labelstring—角色:content
typestring——
descriptionstring——
relstring——
idnumber——
opensInNewTabbooleanfalse—
urlstring—角色:content
titlestring——
kindstring——
isTopLevelItemboolean——
isParentSubmenubooleantrue—

支持功能

通过 block.json 中的 supports 属性定义。

上下文

通过 block.json 中的 usesContext 和 providesContext 属性定义。

使用的上下文:

  • textColor
  • customTextColor
  • backgroundColor
  • customBackgroundColor
  • overlayTextColor
  • customOverlayTextColor
  • overlayBackgroundColor
  • customOverlayBackgroundColor
  • fontSize
  • customFontSize
  • showSubmenuIcon
  • maxNestingLevel
  • openSubmenusOnClick
  • submenuVisibility
  • style

提供的上下文:

  • core/isInsideSubmenu → 属性 isParentSubmenu

CSS 选择器

通过 block.json 中的 selectors 属性定义。

  • 阴影:.wp-block-navigation-submenu > .wp-block-navigation__submenu-container

块标记

这是一个 混合块。它保存静态标记,服务器在渲染时可能会对其进行增强。

<!-- wp:navigation-submenu {"label":"A fine submenu","isTopLevelItem":true} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://wordpress.org/"} -->
<!-- /wp:navigation-link -->
<!-- /wp:navigation-submenu -->

来源