Pages and navigation
Pages and navigation from the Pages module
With BarakoCMS.Pages installed, the CMS owns the page tree: which pages are in the menu, their
order, their nesting and each page's path. Mount it with pages:
export const config = defineConfig({ sites: {}, pages: "" });
"" is the site root. "/docs" serves the CMS page at /about on /docs/about. Leaving pages out
means the site has no page tree, and nothing below asks for one. Then one catch-all route,
app/[[...path]]/page.tsx, or app/[...path]/page.tsx when app/page.tsx keeps /:
import { createPage, createPageMetadata } from "barakopress";
import { blocks, config } from "@/press.config";
export default createPage(config, blocks);
export const generateMetadata = createPageMetadata(config);
export const revalidate = 300;
createPagereadsGET /api/public/pages/resolve?path=and renders the page's blocks, or its body, with breadcrumbs above the title when the page has a parent. Mounted on a[slug]route instead, it reads the page type by slug as before.createSiteLayoutdrawsGET /api/public/pages/navigationin the header.Navigationdraws the items in the order it received them and links to the paths it was given, under the mount. It does not sort, nest, filter or derive a path. A menu that cannot be read is no menu, not a broken page, and while holding the holding page is left out of it.- A miss asks
GET /api/public/redirects/resolve?path=before it is a 404, because a catch-all is where a rebuilt site's old URLs land. A 301 answers as a permanent redirect and anything else as a temporary one. A destination that is not a site path or an http or https URL is ignored. - Reserved slugs. Next answers a static route before a catch-all, so a root page slugged
blogorfeed.xmlwould silently never render. At the root mount, a path whose first segment is reserved is a 404 and is never asked for, and it is left out of the sitemap and static params with a warning. The list is the first segment of each configured route plusapi,feed.xml,sitemap.xml,robots.txt,_next,_shareandfavicon.ico;reservedSlugsadds to it. Give barakoCMS the same list asModules:Pages:ReservedSlugsand an editor is refused the slug on save. - Contract. Both bodies carry
contract, and this renderer reads the range inPAGES_CONTRACT(1 to 1). A body outside it logs a warning and reads as absent: no menu, no page. A public site does not stop rendering because a menu shape moved. - The sitemap lists the pages in the menu, and
createPageStaticParamsreturns their path segments on a build-time site, because the module publishes no other public list of paths. A page outside the menu renders on request.
Navigation, Breadcrumbs, getNavigation(config), getPageByPath(config, path),
getRedirect(config, path) and pageHref(config, path) are exported for a site that draws its own
layout. Every read goes through the same tagged, cached, per tenant read as the rest of the site.