Skip to main content

molecules

Main pages list

A list of the site's main navigation links. The entry matching the current URL becomes plain text marked as the current page.

Specimens

Primary navigation The current URL is "/work/", so that entry is a span.
{{ MainPages.render({
  currentUrl: "/work/",
  classes: "flex flex-row list-none divide-x divide-neutral-700",
  items: [
    { key: "Work", url: "/work/" },
    { key: "About", url: "/about/" },
    { key: "Contact", url: "/contact/" }
  ],
  styles: { item: "px-4 text-center", link: "text-primary-300" }
}) }}

Params

ParamTypeDescription
itemsarrayNavigation entries (url or href, plus title or key). Entries without a link or label are skipped, and so are entries with hide: true (set under eleventyNavigation in a page’s frontmatter; the page still builds). Defaults to empty.
currentUrlstringThe matching entry renders as a <span aria-current="page"> instead of a link.
classesstring, variant map, or arrayApplied to the <ul> through classes.
stylesobjectSlot map. See the slot table.
SlotElement
itemEach <li>.
linkThe link, or the current-page <span>. Passed to the nav link as its classes.
childrenOpt-in. An object with list, item and link class maps. When given, an entry with a non-empty children array renders a nested <ul role="list"> inside its <li> (the macro calls itself, so nested entries follow the same rules). Without it, children are ignored.

Notes

Items need a url or href and a title or key, and any other entry is skipped.