@@ -10,7 +10,7 @@ type Props = {
1010 title? : string ;
1111 description? : string ;
1212 lang? : " pl" | " en" ;
13- routeKey: RouteKey ;
13+ routeKey? : RouteKey ;
1414 routeParams? : RouteParams ;
1515};
1616
@@ -23,10 +23,10 @@ const {
2323} = Astro .props as Props ;
2424
2525const baseUrl = " https://rocketdeploy.dev" ;
26- const { pl : plPath, en : enPath } = getRoutePaths (routeKey , routeParams );
27- const plUrl = new URL (plPath , baseUrl ).toString ();
28- const enUrl = new URL (enPath , baseUrl ).toString ();
29- const canonicalUrl = lang === " pl" ? plUrl : enUrl ;
26+ const routePaths = routeKey ? getRoutePaths (routeKey , routeParams ) : null ;
27+ const plUrl = routePaths ? new URL (routePaths . pl , baseUrl ).toString () : null ;
28+ const enUrl = routePaths ? new URL (routePaths . en , baseUrl ).toString () : null ;
29+ const canonicalUrl = routePaths ? ( lang === " pl" ? plUrl : enUrl ) : null ;
3030---
3131
3232<!doctype html >
@@ -42,16 +42,16 @@ const canonicalUrl = lang === "pl" ? plUrl : enUrl;
4242 { description && <meta property = " og:description" content = { description } />}
4343 { description && <meta name = " twitter:description" content = { description } />}
4444
45- <link rel =" canonical" href ={ canonicalUrl } />
46- <link rel =" alternate" hreflang =" pl" href ={ plUrl } />
47- <link rel =" alternate" hreflang =" en" href ={ enUrl } />
48- <link rel =" alternate" hreflang =" x-default" href ={ enUrl } />
45+ { canonicalUrl && <link rel = " canonical" href = { canonicalUrl } />}
46+ { plUrl && <link rel = " alternate" hreflang = " pl" href = { plUrl } />}
47+ { enUrl && <link rel = " alternate" hreflang = " en" href = { enUrl } />}
48+ { enUrl && <link rel = " alternate" hreflang = " x-default" href = { enUrl } />}
4949 </head >
5050
5151 <body >
5252 <div class =" header" >
5353 <div class =" container" >
54- <Header lang ={ lang } routeKey ={ routeKey } routeParams ={ routeParams } />
54+ <Header lang ={ lang } routeKey ={ routeKey ?? " home " } routeParams ={ routeParams } />
5555 </div >
5656 </div >
5757
0 commit comments