Implement Client-Specific Content Routing in Astro
Client-Specific Content Routing Implementation
π Objective
Implement a routing system that allows serving client-specific content while maintaining the existing general content structure. Client-specific content should be accessible under
/:client/*
routes and should be able to reference general content, but not vice versa.Begin to implement a separation of concerns in regard to content config TypeScript. We have bundled all content configuration in a single content.config.ts file and we should use this opportunity to create the client-specific collections in their own config files.
ποΈ System Architecture
Current Structure
graph TD
A[General Content] -->|Rendered by| B[Existing Layouts]
B --> C[Public Routes]
Target Structure
graph TD
A[General Content] -->|Rendered by| B[Existing Layouts]
B --> C[Public Routes]
D[Client Content] -->|Extends| A
D -->|Rendered by| E[Client Layouts]
E --> F[/:client/* Routes]
π― Requirements
1. Content Organization
- Client-specific content lives in
content/client-content/{client-name}/
- Example test case:
content/client-content/Laerdal/Recommendations
2. Routing
Implement the following dynamic routes:
/:client
- Client landing page/:client/:collection
- Collection view (usingCollectionReaderLayout
)/:client/:collection/:slug
- Content item view (usingContentItemReaderLayout
)
3. Technical Implementation
- Use Astro's file-based routing system
- Extend existing layout components for client-specific variations
- Maintain separation between general and client-specific content
- Ensure client routes don't conflict with existing routes
π Reference Implementations
Similar Patterns
site/src/pages/learn-with/*
- Example of content collectionsite/src/pages/more-about/*
- Another content collection example
Existing Render Pipeline for re-use:
site/src/layouts/CollectionReaderLayout.astro
- Base layout to extendsite/src/components/articles/ContentNavSidebar.astro
site/src/components/articles/EntryListColumn.astro
site/src/components/articles/EntryListItemPreview--Base.astro
- Item layout to extend
π οΈ Development Tasks
- Setup Client Content Structure
- Create base directory:
content/client-content
- Add test client:
content/client-content/Laerdal/Recommendations
- Add sample markdown files for testing
- Implement Dynamic Routes
- Create
site/src/pages/[...client].astro
for client routes - Implement route parameter handling
- Add 404 handling for invalid clients
- Testing
- Verify all routes work as expected
- Test one client-specific content collection in isolation
- Verify general content remains accessible
π Additional Context
Monorepo Structure
- Main repo: lossless-monorepo
- Site code: lossless-site
- Content: lossless-content
Future Considerations
- Authentication for client-specific content
- Client-specific theming
- Content sharing between clients
β Success Criteria
- Client routes are accessible and functional
- General content remains completely unchanged
- Client-specific content is properly isolated in its own routes
- Links from client content to general content work correctly
- Few modifications needed to existing layouts or components, preference for changes only making "hard-coded" collections and routes to variable collections.
- Reused as much as possible from existing code
- Code follows project patterns and style
- Documentation is updated
π Notes
- Use MDX for client content to enable interactive components
- Consider using Astro content collections for better type safety
- Implement proper error boundaries and loading states