Skip to content

Commit 5158571

Browse files
committed
fix: URL lang when no localStorage pref
1 parent a588466 commit 5158571

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pages/cre/[...id].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ if (isCanonical) {
122122
is:inline
123123
slot="head-scripts"
124124
define:vars={{ goUrl: `/cre/${goEntry.id}`, tsUrl: `/cre/${tsEntry.id}`, currentLang: entry!.data.sdkLang }}
125-
set:html={`(function(){try{var s=localStorage.getItem("docs-language-preference"),l=s==="ts"||s==='"ts"'?"ts":"go";if(l!==currentLang){var u=l==="ts"?tsUrl:goUrl;u&&window.location.replace(u)}}catch(e){}})();`}
125+
set:html={`(function(){try{var s=localStorage.getItem("docs-language-preference");if(s){var l=s==="ts"||s==='"ts"'?"ts":"go";if(l!==currentLang){var u=l==="ts"?tsUrl:goUrl;u&&window.location.replace(u)}}else{try{localStorage.setItem("docs-language-preference",currentLang)}catch(e){}}}catch(e){}})();`}
126126
/>
127127
)
128128
)

0 commit comments

Comments
 (0)