File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const t = useTranslations(lang);
2222 <p class =" uppercase text-3xl text-zinc-900" >blog</p >
2323 </a >
2424 <ul class =" flex gap-x-8" >
25- <li ><a href =" / " class =" text-teal-900 font-bold" >{ t (' nav.home' )} </a ></li >
25+ <li ><a href ={ ` /${ lang }/ ` } class =" text-teal-900 font-bold" >{ t (' nav.home' )} </a ></li >
2626 <li ><a href ={ ` /${lang }/about ` } class =" text-teal-900 font-bold" >{ t (' nav.about' )} </a ></li >
2727 <li ><a href ={ ` /${lang }/blog ` } class =" text-teal-900 font-bold" >Blog</a ></li >
2828 <li ><ThemeDropdown name =" theme" ></ThemeDropdown ></li >
Original file line number Diff line number Diff line change 11---
22import { languages } from ' ../i18n/ui' ;
33import { getLangFromUrl } from ' ../i18n/utils' ;
4+ import blog from " ../data/blog.json" ;
45
5- function getPath(){
6+ function getIndex(aux : string , lang : string ){
7+ var filteredObj = blog .find (function (item , i ){
8+ if (lang == ' en' ){
9+ if (item .en === aux ){
10+ return i ;
11+ }
12+ }
13+ else {
14+ if (item .ptbr === aux ){
15+ return i ;
16+ }
17+ }
18+ });
19+ return 0 ;
20+ }
21+
22+ function getPath(lang_org : string ){
623 let lang = getLangFromUrl (Astro .url );
24+ var url = Astro .url .pathname .split ( ' /' );
25+ var title = ' ' ;
26+ console .log (url )
27+ console .log (blog [0 ].en )
28+ if (url .length > 3 && (url [2 ] == ' blog' || url [2 ] == ' portfolio' )){
29+ var aux = url [3 ];
30+ if (lang_org == ' en' ){
31+ var i = getIndex (aux , lang );
32+ title = blog [i ].en
33+ }else {
34+ var i = getIndex (aux , lang );
35+ title = blog [i ].ptbr
36+ }
37+ console .log (" oiii" );
38+ var string = Astro .url .pathname ;
39+ console .log (string );
40+ string = string .replace (` /${lang }/ ` , ' ' );
41+ console .log (string );
42+ string = string .replace (` /${url [3 ]} ` , ` /${title } ` );
43+ console .log (string );
44+ return string ;
45+ }
746 return Astro .url .pathname .replace (` /${lang }/ ` , ' ' );
847}
948
1049---
1150<ul >
1251 { Object .entries (languages ).map (([lang , label ]) => (
1352 <li >
14- <a href = { ` /${lang }/${getPath ()} ` } >{ label } </a >
53+ <a href = { ` /${lang }/${getPath (lang )} ` } >{ label } </a >
1554 </li >
1655 ))}
1756</ul >
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "en" : " hello.mdx" ,
4+ "ptbr" : " ola.mdx"
5+ }
6+ ]
You can’t perform that action at this time.
0 commit comments