Edit this page

up.status [up-alias]
HTML selector

Links within navigational containers may use the [up-alias] attribute to define alternative URLs for which they should also be highlighted as .up-current.

See Highlighting links for multiple URLs for more documentation.

Example

The link below will be highlighted with .up-current at both /profile and /profile/edit locations:

<nav>
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fprofile" up-alias="/profile/edit">Profile</a>
</nav>

To configure multiple alternative URLs, use a URL pattern.

Setting URL aliases from macros

An [up-alias] attribute can be set by a macro.

This can be useful to link nested navigation trees programmatically.
Let's say we have a main navigation linking to two sections:

<nav class="main-nav">
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fcompanies" data-section="companies"> <!-- mark: data-section="companies"-->
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fusers" data-section="users"> <!-- mark: data-section="users"-->
</nav>

We also have a sub-navigation for each section:

<nav class="sub-nav" data-section="companies"> <!-- mark: data-section="companies"-->
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fcompanies">All companies</a>
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fcompanies%2Fsync">Sync CRM</a>
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fcompanies%2Fexport">Export</a>
</nav>

<nav class="sub-nav" data-section="users"> <!-- mark: data-section="users"-->
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fusers">All users</a>
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fusers%2Fonline">Now online</a>
  <a href="/?originalUrl=https%3A%2F%2Funpoly.com%2Fusers%2Fprofile">Your profile</a>
</nav>

We want the main navigation section to be .up-current for any sub-section URL. We can do that with a macro that finds the respective sub-navigation, and sets an [up-alias] attribute at the main navigation link:

up.macro('.main-nav a', function(link, { section }) {
  let subLinks = document.querySelectorAll(`.sub-nav[data-section="${section}"]`)
  let subURLs = up.util.map(subLinks, 'href')
  link.setAttribute('up-alias', subURLs.join())
})

Modifying attributes

up-alias
required

A URL pattern with alternative URLs.