Skip to content

Latest commit

 

History

History
45 lines (30 loc) · 2.04 KB

File metadata and controls

45 lines (30 loc) · 2.04 KB

Nodes

A node is a container, similar to an object, that holds fields describing its content, how that content should be displayed, and a name (similar to an ID) that allows it to be queried.

✨ Defining Nodes

Nodes are defined using the np-node attribute on an element in the body. The value of this attribute serves as the node’s identifier used when querying across pages.

While you’re free to use custom names, we recommend using reserved node names to ensure consistency and standardization.

<article np-node="primary">
    ...
</article>

Nodes can also be declared in the <head> of the document as fallbacks, providing a global fallback node for when a queried node is invalid or not defined.

<head>
    <meta name="np:node" content="primary">
    ...
</head>

📥 Reserved Node Names

Reserved nodes provide a standardized way to categorize the granularity of the content being queried. You can declare one of five predefined values, each representing a specific level or type of content.

  • primary: The core information about the subject of the page.

  • secondary: Nuanced or extended information about the subject of the page.

  • tertiary: Loosely related or adjacent information about the subject.

  • important: Represents an important note on the data, but not necessarily the data itself. This is usually temporary data and will revert to "primary" if queried but not explicitly defined.

  • warning: Describes cautionary messages, such as warnings and errors related to the subject of the page. This is typically a temporary node and will result in null if queried but not explicitly defined.

🚨 Node Failover Strategy

When a client queries a node that is either undefined or invalid, the system initiates a failover strategy.

  1. It first searches for a node named Primary,
  2. If a node named primary is not found, it checks for any node defined as a fallback in the document’s <head>.

If no valid node is available at any level, the query returns null.