Skip to content

Commit

Permalink
fix(seo2): correct generate alternate links
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Sep 24, 2022
1 parent 67f8ec8 commit 347bff8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions packages/seo2/src/node/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,23 @@ export const getJSONLD = (
export const getCanonicalLink = (
page: ExtendPage,
options: SeoOptions
): string | null => {
if (typeof options.canonical === "function") return options.canonical(page);

if (typeof options.canonical === "string")
return `${removeEndingSlash(options.canonical)}${page.path}`;

return null;
};
): string | null =>
typeof options.canonical === "function"
? options.canonical(page)
: typeof options.canonical === "string"
? `${removeEndingSlash(options.canonical)}${page.path}`
: null;

export const getAlternateLinks = (
page: ExtendPage,
app: App
): { lang: string; path: string }[] => {
const locales = getLocales(page.lang, app.siteData.locales);

return locales.map(({ lang, localePath }) => ({
{ hostname }: SeoOptions,
{ options, siteData }: App
): { lang: string; path: string }[] =>
getLocales(page.lang, siteData.locales).map(({ lang, localePath }) => ({
lang,
path: `${localePath}${page.path.replace(page.pathLocale, "")}`,
path: resolveUrl(
hostname,
options.base,
`${localePath}${page.path.replace(page.pathLocale, "")}`
),
}));
};
2 changes: 1 addition & 1 deletion packages/seo2/src/node/seo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const appendSEO = (
: null;

const canonicalLink = getCanonicalLink(page, options);
const alternateLinks = getAlternateLinks(page, app);
const alternateLinks = getAlternateLinks(page, options, app);

addOGP(head, ogpContent);
appendJSONLD(head, jsonLDContent);
Expand Down

0 comments on commit 347bff8

Please sign in to comment.