feat: add configurable slug-to-publication mapping system
Replace hardcoded blog routes with a flexible slug mapping system that allows multiple publications to be accessed via friendly URLs.
BREAKING CHANGES:
- Routes moved from /blog/* to /[slug]/* (configurable)
- Environment variables removed: PUBLIC_LEAFLET_BASE_PATH, PUBLIC_LEAFLET_BLOG_PUBLICATION
- New config file required: src/lib/config/slugs.ts
New Features:
- Add slug-to-publication-rkey mapping in src/lib/config/slugs.ts
- Support multiple publications with different URL slugs
- Each publication can use its own base_path from Leaflet API
- Maintain all existing redirect logic and platform detection
Changes:
- Create src/lib/config/slugs.ts with SlugMapping interface
- Add helper functions: getPublicationRkeyFromSlug, getSlugFromPublicationRkey, getAllSlugs
- Migrate /blog/+server.ts to /[slug]/+server.ts with slug validation
- Migrate /blog/[rkey]/+server.ts to /[slug]/[rkey]/+server.ts with publication filtering
- Migrate /blog/rss/+server.ts to /[slug]/rss/+server.ts with slug-based filtering
- Migrate /blog/atom/+server.ts to /[slug]/atom/+server.ts with slug validation
- Remove PUBLIC_LEAFLET_BASE_PATH priority in posts.ts (rely on publication base_path)
- Update README.md with new configuration instructions and examples
Migration Guide:
1. Create src/lib/config/slugs.ts with your publication mappings
2. Remove PUBLIC_LEAFLET_BASE_PATH and PUBLIC_LEAFLET_BLOG_PUBLICATION from .env
3. Access publications via /{slug} instead of /blog (default slug: 'blog')