Documentation content rendering and navigation
The documentation content system turns the Angular page tree into a browsable reference site. It combines file-based routes with authored page components, live examples, generated reference data, public assets, shared styling, and client-side navigation. This page is a focused companion to the Spartan documentation application.
Route organization
File-based documentation routes
The documentation app uses Analog file routes. Files named *.page.ts define pages, index.page.ts defines a parent route, and folders in parentheses group pages without adding those group names to the public URL. The docs root redirects to /documentation/introduction, while a catch-all page provides the docs fallback for unknown paths.
The route tree separates broad content areas from the documentation group:
- Getting-started pages live below
/documentation. - UI guidance and utility pages use nested folders below the same route.
- Component pages live below
/componentsand use the same page conventions. - Preview and example files support pages but do not become public routes.
This organization lets the source tree group related files while keeping URLs short and stable.
References: apps/…/documentation.page.ts• L1-20 apps/…/index.page.ts• L1-6 apps/…/[...not-found].page.ts• L1-24 apps/…/prerender-routes.ts• L9-20
Route metadata
Each page supplies route metadata for the browser title, search description, and breadcrumb label. Component pages also identify the component whose generated API data should be shown. The metadata becomes part of the page's public identity and connects the route to the shared navigation surfaces.
Pages use the shared metaWith shape for descriptions and social preview fields. A route can also mark a data-loading state or provide a function for a breadcrumb label when the label depends on route data.
References: apps/…/introduction.page.ts• L19-26 apps/…/tooltip.page.ts• L33-40 apps/…/meta.util.ts• L1-51 apps/…/breadcrumb.service.ts• L22-53
Content rendering
Documentation page composition
The documentation frame places the active route inside a common reading layout. The application shell owns the header and footer. The documentation page adds a left section menu, a central route outlet, and a right page-navigation outlet for same-page links.
The page content is authored as standalone Angular components. A page normally starts with a main section and section introduction. It can then combine text, headings, links, install controls, previews, code panels, and bottom navigation without changing the outer frame.
References: apps/…/app.ts• L19-30 apps/…/documentation.page.ts• L13-20 apps/…/page.ts• L7-29 apps/…/main-section.ts• L1-9 apps/…/section-intro.ts• L6-31
Example and code surfaces
Examples are Angular components that a page places into a preview surface. The related source is shown in a code surface so a reader can compare the result with the code needed to create it. A two-tab presentation keeps preview and code together, while nested tabs support variants such as Angular CLI and Nx commands.
Code display supports common source languages, syntax highlighting, file labels, clipboard copy, and a runnable-example action when the source can be opened as a self-contained Spartan example. A preview receives the current style as an island-level class so the example can demonstrate a style without changing the whole page.
The content path is:
flowchart LR
A[Page component] --> B[Example component]
A --> C[Example source]
B --> D[Styled preview]
C --> E[Highlighted code]
E --> F{Runnable example?}
F -- No --> G[Copy source]
F -- Yes --> H[Open in StackBlitz]
References: apps/…/tooltip.page.ts• L72-93 apps/…/tooltip.preview.ts• L1-12 apps/…/tabs.ts• L11-72 apps/…/code.ts• L23-59 apps/…/code.ts• L61-215 apps/…/code-preview.ts• L4-15
Generated component reference data
Component pages combine authored explanations with generated data for API details, primitive snippets, manual installation text, and runnable-project metadata. The page loader fetches the slices for the active component from public data URLs. Shared services then expose the loaded data to the API tables, install controls, code panels, and StackBlitz action.
Optional slices may be absent when a component does not provide that kind of content. An expected missing slice becomes empty content. Other request failures remain visible as errors so the page does not silently present a partial reference.
References: apps/…/component-docs-loader.ts• L7-30 apps/…/component-docs.ts• L12-33 apps/…/ui-docs-section.ts• L11-120 apps/…/install-tabs.ts• L25-49
Asset loading
Public asset delivery
Static images, fonts, icons, and generated documentation data are served from the app's public directory. Vite exposes that directory at the site root. Nitro also treats generated data as server assets, so server-side page loading and browser-side controls use the same URL family.
The build and serve targets generate UI documentation and preview data before the app runs. This keeps the displayed API and install content tied to the current Brain and Helm source rather than to a separately maintained copy.
References: apps/…/vite.config.ts• L12-22 apps/…/vite.config.ts• L141-151 apps/…/project.json• L75-99 apps/…/component-docs-loader.ts• L17-30
Runnable example assets
The StackBlitz flow assembles an external Angular project from generated project files and the selected example. It rewrites root-relative /assets paths to the live documentation origin because the external project does not own the docs site's asset directory. Relative example files are included when the generated file map contains them; an unresolved sibling stops the open action instead of creating a broken project.
The StackBlitz SDK loads only after the user asks to open an example. This keeps the browser bundle and server-rendering path separate from the browser-only external project handoff.
References: apps/…/stackblitz-project-builder.service.ts• L16-17 apps/…/stackblitz-project-builder.service.ts• L41-103 apps/…/stackblitz-project-builder.service.ts• L105-191 apps/…/open-in-stackblitz-button.ts• L46-82 apps/…/stackblitz.service.ts• L5-21
Global styling
Theme and style state
Global styling gives the site a shared visual base while allowing previews to show a selected Spartan component style. The page-wide theme controls manage dark mode, color theme, layout mode, and logo variant. These choices are reflected through document classes and browser storage where the choice should persist.
The style selector used by component previews is separate from the page color theme. It starts with the Nova style and lets installation tabs and preview islands use one of the registered styles. This separation prevents a component style demonstration from changing the documentation chrome.
References: apps/…/theme.service.ts• L16-46 apps/…/theme.service.ts• L48-127 apps/…/theme.service.ts• L130-164 apps/…/style.service.ts• L1-9 apps/…/style-options-dropdown.ts• L11-40
Preview and overlay styling
The global stylesheet loads the registered style bundles, Tailwind layers, fonts, theme variables, and shared layout utilities. Preview containers carry a style-* class so the selected component style applies inside the preview boundary.
Angular CDK overlays use one shared DOM container. The app resolves the style of the last interaction trigger and stamps that style on the overlay container. As a result, a menu or popover opened from a themed preview matches that preview, while site chrome keeps the default style.
References: apps/…/styles.css• L1-53 apps/…/styles.css• L55-152 apps/…/code-preview.ts• L4-15 apps/…/code-rtl-preview.ts• L11-67 apps/…/style-aware-overlay-container.ts• L7-57 apps/…/app.config.ts• L17-22
Client-side navigation
Site and section navigation
The navigation model defines the site's top-level destinations and the grouped links shown in the documentation sidebar. Desktop users get a persistent left sidebar. Smaller screens get a full-screen menu that uses the same navigation data, which keeps the two layouts aligned.
Links can mark work-in-progress and new content. Work-in-progress items do not navigate, while new items display a marker. Active links use the router state so the current section stays visible in the navigation context.
References: apps/…/navigation-items.ts• L1-21 apps/…/navigation-items.ts• L97-151 apps/…/side-nav.ts• L1-68 apps/…/header-mobile-nav.ts• L11-98 apps/…/header.ts• L40-108
Same-page navigation
The right-side page index is built from headings in the active main section. Section headings form the main entries, and ordinary h3 headings form nested entries. Each entry links to the heading's fragment ID, so the page index and search results can land on a stable section within the page.
Component pages can add generated Brain and Helm API entries to this index. The API sections act as insertion points for the generated headings, which keeps generated details close to the matching API heading without requiring each component page to list those entries by hand.
References: apps/…/page-nav.ts• L23-49 apps/…/page-nav.ts• L77-144 apps/…/page-nav-link.ts• L4-25 apps/…/page-nav-outlet.ts• L4-17 apps/…/ui-docs-section.ts• L18-22
Route transitions and page links
Client-side routing preserves the single-page app experience while keeping fragment and scroll behavior useful for documentation. The router enables anchor scrolling and scroll-position restoration. It preloads route modules so moving between reference pages does not require a new full document load.
Pages also provide previous and next links at the bottom of the main section. These links resolve either from the active route or from an absolute path, which lets a page move within its current group or cross to another site area.
References: apps/…/app.config.ts• L1-19 apps/…/page-bottom-nav.ts• L3-11 apps/…/page-bottom-nav-link.ts• L7-40 apps/…/styles.page.ts• L192-199
Display behavior
The page frame adapts its reading surfaces to the viewport. The left sidebar is a desktop surface, the right page index appears at extra-large widths, and the mobile header supplies the compact navigation menu. Code areas scroll within their own bounds, while long API tables and page indexes avoid forcing the whole page to widen.
Documentation previews can also show direction and language changes. RTL preview controls select English, Arabic, or Hebrew content and apply the matching font family. This behavior demonstrates display changes inside the preview without changing the route or the surrounding page structure.
References: apps/…/side-nav.ts• L14-22 apps/…/page-nav-outlet.ts• L6-14 apps/…/code.ts• L134-146 apps/…/ui-api-docs-table.ts• L9-40 apps/…/code-rtl-preview.ts• L25-80 apps/…/styles.css• L146-152
Change checklist
When these files or sections are changed, remember to consider these:
- New or moved page files must stay aligned with the public navigation model and the prerender route list. Parentheses group source files but must not appear in the public URL.
- Heading changes must preserve fragment IDs used by the page index and by links that target a section.
- Generated data URL or shape changes must stay aligned across the generation targets, Nitro assets, page loaders, and shared data services.
- Example source changes must preserve the runnable-example boundary and the generated sibling-file map used by StackBlitz.
- Style additions must be included in the registered style list, global style imports, preview classes, and style-specific install content.
- Overlay behavior changes must preserve the style of the trigger that opened the overlay rather than applying one style to all overlays.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A page is added without its navigation or prerender entry | The route may work by direct client navigation but remain hard to discover or absent from static output. | Update the shared navigation model and the relevant prerender route source. |
| A section heading loses its stable ID | The page index and deep links cannot reach the intended section. | Keep explicit fragment IDs on headings used as navigation targets. |
| A generated data slice uses a different URL or shape | Component API, install, or example content becomes empty or fails to load. | Keep generator output, public asset paths, loader types, and shared services in sync. |
| A runnable example imports an unavailable sibling or docs-only module | StackBlitz opens an incomplete or unusable project. | Keep bundled sibling files available and reject non-self-contained examples. |
| A preview overlay uses a global style instead of its trigger style | Menus, dialogs, or popovers can look wrong when opened inside a themed preview. | Resolve and apply the nearest style-* class from the interaction trigger. |
| A public asset path is used unchanged in StackBlitz | Images or other assets return 404 in the external project. | Rewrite root-relative asset paths to the live docs origin before project creation. |
Key files
| File | Why to read it |
|---|---|
| apps/…/documentation.page.ts | Shows the documentation route entry into the shared page frame. |
| apps/…/prerender-routes.ts | Shows how source page files become public prerender routes. |
| apps/…/page.ts | Shows the relationship between the route outlet, left sidebar, and right page index. |
| apps/…/navigation-items.ts | Defines top-level and grouped navigation relationships. |
| apps/…/page-nav.ts | Shows how page headings and generated API headings become same-page links. |
| apps/…/tabs.ts | Shows the common preview-and-code presentation unit. |
| apps/…/code.ts | Shows code display, copy behavior, language handling, and runnable-example detection. |
| apps/…/component-docs-loader.ts | Shows the public data slices loaded for component pages. |
| apps/…/stackblitz-project-builder.service.ts | Shows how an example becomes a self-contained external project. |
| apps/…/styles.css | Defines global layers, theme variables, fonts, and shared display rules. |
| apps/…/style-aware-overlay-container.ts | Shows how overlays keep the style of their opening context. |
| apps/…/app.config.ts | Defines client-side scrolling, preloading, hydration, and overlay configuration. |
| Documentation application | Parent page for the complete application shell and delivery model. |
| Documentation server APIs and notes | Related page for server data and persisted notes. |
| Storybook and integration testing | Related page for browser checks and integration coverage. |