导航块是用于容纳允许访客浏览您网站的各类块的容器块。另见“导航链接”块和“导航子菜单”块。

CSS 类

导航块的结构性 CSS 针对多种菜单项的通用类名,包括由页面列表块自动生成的那些。以下是一些值得注意的类名及其用途:

  • .wp-block-navigation__submenu-container 应用于主菜单项的子菜单。
  • .wp-block-navigation-item 应用于每个菜单项。
  • .wp-block-navigation-item__content 应用于菜单项内的链接。
  • .wp-block-navigation-item__label 应用于围绕菜单项文本标签的最内层容器。
  • .wp-block-navigation-item__description 应用于围绕菜单项描述的最内层容器。
  • .wp-block-navigation__submenu-icon 应用于子菜单指示器(倒三角)。

允许访客浏览您网站的块集合。

  • Name: core/navigation
  • Category: theme
  • API Version: 3
  • Block Type: Hybrid(静态保存 + 服务器增强)
  • Keywords: menu, navigation, links

块关系

允许的内部块:
– core/navigation-link
– core/search
– core/social-links
– core/page-list
– core/spacer
– core/home-link
– core/icon
– core/site-title
– core/site-logo
– core/navigation-submenu
– core/loginout
– core/buttons

属性

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

属性类型默认值描述
refnumber——
textColorstring——
customTextColorstring——
rgbTextColorstring——
backgroundColorstring——
customBackgroundColorstring——
rgbBackgroundColorstring——
showSubmenuIconbooleantrue—
submenuVisibilitystring"hover"枚举:hover, click, always
overlayMenustring"mobile"—
overlaystring——
iconstring"handle"—
hasIconbooleantrue—
__unstableLocationstring——
overlayBackgroundColorstring——
customOverlayBackgroundColorstring——
overlayTextColorstring——
customOverlayTextColorstring——
maxNestingLevelnumber5—
templateLockstring \| boolean—枚举:all, insert, contentOnly, false

支持

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

上下文

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

提供上下文:

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

区块标记

这是一个 混合区块。它保存服务器在渲染过程中可能进行增强的静态标记。

<!-- wp:navigation -->
<!-- /wp:navigation -->

来源