Chapter Nav

Next before previous; chapters wrap.

HANDLE
chapter-nav
LIVES IN
src/components/Editorial.jsx (ChapterNav)
USED ON
Foot of every chapter and every build page
PROPS
prev · next · heading · hrefFor · metaFor · back (defaults are the chapters)
CODE
COPY AND PASTE

How it is called.

JSX
import { ChapterNav } from '../components/Editorial.jsx'
import { getNeighbors } from '../data/projects.js'

const { prev, next } = getNeighbors(slug)
<ChapterNav prev={prev} next={next} />

// On a build page
<ChapterNav
  prev={prev}
  next={next}
  heading="¶ BUILDS"
  hrefFor={(b) => `/builds/${b.slug}`}
  metaFor={(b) => b.stack[0]}
  back={{ href: '/#builds', label: 'ALL BUILDS' }}
/>
RULES

What must stay true.

Next before previous; chapters wrap.