Multi-Subsite Architecture
The Lynx website operates as a collection of "mini-subsites" (e.g., Lynx, ReactLynx, Rspeedy) housed within a single repository. This architecture allows each subsite to have its own identity (logo, home page, sidebar) while sharing common documentation and infrastructure.
Configuration
The central configuration for subsites is located in shared-route-config.ts. This file acts as the single source of truth for:
- Subsite Metadata: Defines the list of available subsites.
- Shared Routes: Defines which documentation sections are shared across subsites.
SubsiteConfig
Each subsite is defined by a SubsiteConfig object:
Adding a New Subsite
To add a new subsite (e.g., my-framework):
- Create Directory: Create
docs/en/my-framework/(anddocs/zh/my-framework/). - Update Config: Add a new entry to
SUBSITES_CONFIGinshared-route-config.ts. - Configure Sidebar: Create
docs/en/my-framework/_meta.jsonto define its specific sidebar structure.
Shared Documentation
To avoid duplicating content (like "Quick Start" guides) across multiple subsites, we use a shared documentation system.
How it Works
- Source of Truth: Shared files are physically located in
docs/en/guide/start/. - Virtual Routes: The
sharedSidebarPlugininrspress.config.tsdynamically creates virtual pages for other subsites (e.g.,react/start/quick-start) that point to the same content. - Unified Sidebar: The
BeforeSidebarcomponent (intheme/BeforeSidebar.tsx) automatically injects the shared "Start" section into the sidebar of every subsite.
Managing Shared Content
To modify which files are shared, update SHARED_DOC_TITLES in shared-route-config.ts.
Subsite UI
The subsite navigation and identity are handled by custom theme components:
SubsiteSelect(theme/BeforeSidebar.tsx): The dropdown menu at the top of the sidebar allows users to switch between subsites.SubsiteLogo(theme/subsite-ui.tsx): Renders the correct logo for the current subsite and theme mode.
These components read directly from SUBSITES_CONFIG, so any changes there are immediately reflected in the UI.