docs: canonical url fix (#27554)

canonical wrong on e.g.
https://python.langchain.com/v0.1/docs/modules/agents/concepts/
This commit is contained in:
Erick Friis 2024-10-22 12:46:18 -07:00 committed by GitHub
parent 3b0e993e20
commit bc6600d86f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,6 +62,9 @@ function useDefaultCanonicalUrl() {
const canonicalPathnameNoVersion = canonicalPathname.startsWith('/v0.') ? "/"+canonicalPathname.split('/').slice(2).join('/') : canonicalPathname; const canonicalPathnameNoVersion = canonicalPathname.startsWith('/v0.') ? "/"+canonicalPathname.split('/').slice(2).join('/') : canonicalPathname;
const suggestedLookup = suggestedLinks[canonicalPathnameNoVersion]; const suggestedLookup = suggestedLinks[canonicalPathnameNoVersion];
const finalPathname = suggestedLookup?.canonical || canonicalPathname; const finalPathname = suggestedLookup?.canonical || canonicalPathname;
if (finalPathname.startsWith("https://")) {
return finalPathname;
}
return siteUrl + finalPathname; return siteUrl + finalPathname;
} }