Skip to content

Commit 397a2f6

Browse files
committed
fix: noindex CRE redirect pages, preserve shared links
1 parent bf816ce commit 397a2f6

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,28 @@ if (isCanonical) {
107107
---
108108

109109
<DocsLayout frontmatter={currentEntry.data} {headings}>
110+
{/* noindex for redirect pages */}
111+
{isCanonical && <meta name="robots" content="noindex, follow" slot="head-scripts" />}
112+
110113
{
111-
isCanonical ? (
114+
isCanonical && (
112115
<script
113116
is:inline
114117
slot="head-scripts"
115118
define:vars={{ goUrl: `/cre/${goEntry!.id}`, tsUrl: `/cre/${tsEntry!.id}` }}
116119
set:html={`(function(){try{var s=localStorage.getItem("docs-language-preference"),l=s==="go"||s==='"go"'?"go":"ts",u=l==="go"?goUrl:tsUrl;u&&window.location.replace(u)}catch(e){tsUrl&&window.location.replace(tsUrl)}})();`}
117120
/>
118-
) : (
119-
goEntry &&
120-
tsEntry && (
121-
<script
122-
is:inline
123-
slot="head-scripts"
124-
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");if(s){var l=s==="go"||s==='"go"'?"go":"ts";if(l!==currentLang){var u=l==="go"?goUrl:tsUrl;u&&window.location.replace(u)}}else{try{localStorage.setItem("docs-language-preference",currentLang)}catch(e){}}}catch(e){}})();`}
126-
/>
127-
)
121+
)
122+
}
123+
124+
{
125+
!isCanonical && goEntry && tsEntry && (
126+
<script
127+
is:inline
128+
slot="head-scripts"
129+
define:vars={{ currentLang: entry!.data.sdkLang }}
130+
set:html={`(function(){try{localStorage.setItem("docs-language-preference",currentLang)}catch(e){}})();`}
131+
/>
128132
)
129133
}
130134

0 commit comments

Comments
 (0)