feat: Simplify URL structure to rmaps.online/<room>
- Move room page from /room/[slug] to /[slug] - Update all navigation links to use /<slug> format - Update share URL generation - Update middleware for subdomain handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
96fea103fd
commit
912104f740
|
|
@ -55,7 +55,7 @@ export default function HomePage() {
|
||||||
localStorage.setItem('rmaps_user', JSON.stringify({ name, emoji }));
|
localStorage.setItem('rmaps_user', JSON.stringify({ name, emoji }));
|
||||||
|
|
||||||
// Navigate to the room (will create it if it doesn't exist)
|
// Navigate to the room (will create it if it doesn't exist)
|
||||||
router.push(`/room/${slug}`);
|
router.push(`/${slug}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleJoinRoom = () => {
|
const handleJoinRoom = () => {
|
||||||
|
|
@ -65,7 +65,7 @@ export default function HomePage() {
|
||||||
|
|
||||||
// Clean the slug
|
// Clean the slug
|
||||||
const cleanSlug = joinSlug.toLowerCase().replace(/[^a-z0-9-]/g, '');
|
const cleanSlug = joinSlug.toLowerCase().replace(/[^a-z0-9-]/g, '');
|
||||||
router.push(`/room/${cleanSlug}`);
|
router.push(`/${cleanSlug}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,11 @@ interface ShareModalProps {
|
||||||
export default function ShareModal({ roomSlug, onClose }: ShareModalProps) {
|
export default function ShareModal({ roomSlug, onClose }: ShareModalProps) {
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
|
|
||||||
// In production, this would be <slug>.rmaps.online
|
// Share URL uses the cleaner /<slug> format
|
||||||
// For now, use path-based routing
|
|
||||||
const shareUrl =
|
const shareUrl =
|
||||||
typeof window !== 'undefined'
|
typeof window !== 'undefined'
|
||||||
? `${window.location.origin}/room/${roomSlug}`
|
? `${window.location.origin}/${roomSlug}`
|
||||||
: `https://rmaps.online/room/${roomSlug}`;
|
: `https://rmaps.online/${roomSlug}`;
|
||||||
|
|
||||||
const subdomainUrl = `https://${roomSlug}.rmaps.online`;
|
const subdomainUrl = `https://${roomSlug}.rmaps.online`;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import type { NextRequest } from 'next/server';
|
||||||
* Routes:
|
* Routes:
|
||||||
* - rmaps.online -> home page
|
* - rmaps.online -> home page
|
||||||
* - www.rmaps.online -> home page
|
* - www.rmaps.online -> home page
|
||||||
* - <room>.rmaps.online -> /room/<room>
|
* - <room>.rmaps.online -> /<room>
|
||||||
*
|
*
|
||||||
* Also handles localhost for development
|
* Also handles localhost for development
|
||||||
*/
|
*/
|
||||||
|
|
@ -36,9 +36,9 @@ export function middleware(request: NextRequest) {
|
||||||
|
|
||||||
// If we have a subdomain, rewrite to the room page
|
// If we have a subdomain, rewrite to the room page
|
||||||
if (subdomain && subdomain.length > 0) {
|
if (subdomain && subdomain.length > 0) {
|
||||||
// Don't rewrite if already on /room/ path
|
// Only rewrite if at root path (subdomain becomes the room)
|
||||||
if (!url.pathname.startsWith('/room/')) {
|
if (url.pathname === '/') {
|
||||||
url.pathname = `/room/${subdomain}${url.pathname === '/' ? '' : url.pathname}`;
|
url.pathname = `/${subdomain}`;
|
||||||
return NextResponse.rewrite(url);
|
return NextResponse.rewrite(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue