-
Notifications
You must be signed in to change notification settings - Fork 5
seo : configure conancial and hreflang alternates (#62) #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "version": 1, | ||
| "skills": { | ||
| "humanizer-zh": { | ||
| "source": "op7418/humanizer-zh", | ||
| "sourceType": "github", | ||
| "skillPath": "SKILL.md", | ||
| "computedHash": "dede9681d9fea5caed2fb9d88656af3024c9ec0136fc833415ffc6e16d762429" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||
| import { locales } from "@/i18n/config"; | ||||||
|
|
||||||
| export function getAlternates(path: string, currentLang: string) { | ||||||
| const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://weftmap.com"; | ||||||
|
|
||||||
| // cleanPath should start with slash if path is not empty, otherwise empty string | ||||||
| const cleanPath = path ? `/${path}` : ""; | ||||||
|
|
||||||
| const languages = locales.reduce((acc, locale) => { | ||||||
| acc[locale] = `${baseUrl}/${locale}${cleanPath}`; | ||||||
| return acc; | ||||||
| }, {} as Record<string, string>); | ||||||
|
|
||||||
| // Set default fallback language version to English | ||||||
| languages["x-default"] = `${baseUrl}/en${cleanPath}`; | ||||||
|
|
||||||
| return { | ||||||
| canonical: `${baseUrl}/${currentLang}${cleanPath}`, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🛡️ Proposed guard-import { locales } from "`@/i18n/config`";
+import { locales, isLocale, defaultLocale } from "`@/i18n/config`";
export function getAlternates(path: string, currentLang: string) {
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://weftmap.com";
+ const lang = isLocale(currentLang) ? currentLang : defaultLocale;
// cleanPath should start with slash if path is not empty, otherwise empty string
const cleanPath = path ? `/${path}` : "";
@@
return {
- canonical: `${baseUrl}/${currentLang}${cleanPath}`,
+ canonical: `${baseUrl}/${lang}${cleanPath}`,
languages,
};
}This is the root cause for the unvalidated 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| languages, | ||||||
| }; | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Emitting hreflang alternates for an auth-gated, per-user saved graph is questionable.
Unlike the homepage/app/docs/graphs index routes,
graphs/${id}is a private, user-specific resource gated byauth()/notFound()and is not translated content. Advertisingcanonical+ per-localelanguageshere tells crawlers each locale serves an equivalent translated page, which isn't true and exposes the existence of specific graph IDs in head tags. Consider omittingalternates(or settingrobots: { index: false }) for saved-graph pages rather than generating locale alternates.🤖 Prompt for AI Agents