Move a site's own list to the navigation
Replace an Astro site’s own list of pages, the src/nav.ts that ascribe init wrote in 0.3, with the project’s navigation in ascribe.nav.
For AI agents: the documentation index is at llms.txt, and this page is available as Markdown.
A site that npx @ascribed/astro init started before 0.4 has its own list of pages, src/nav.ts, which the layout passes as sidebar(entries, { nav, entry }). It keeps working: the sidebar shows the list’s groups in its order, and the build fails when the list leaves out a page, names a file that isn’t one, or names a page twice. This guide moves the site over to the project’s navigation, so the site keeps no list of its own.
Before you start
- Each group of the list is a folder, with its pages in it. A group that isn’t a folder, or a page in a group other than its folder’s, has no place in
ascribe.nav: move the files into the folders you want as sections first, withascribe rename.
Move the list over
- Write
ascribe.navwith the list’s order: a[[sections]]table for each group, in order, with its folder, alabelwhere the group’s label isn’t its own page’s title, andpageswhere the group’s order isn’t the default (Put your pages in order). - Take
navout of the layout’ssidebar()andneighbors()calls:sidebar(entries, { entry })andneighbors(entry, entries). - Delete
src/nav.ts. - Build the site, and compare its sidebar with the one it had.
See also
- The sidebar,
sidebar()and itsnavoption in@ascribed/astro - Navigation, the file’s keys and the default order