From f9dac8ba3708d216850b7f12714279c708664c98 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:54:46 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20canonical=20url=E3=81=AB=E3=82=AF?= =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app.vue b/app.vue index 2bb3ce78..41c8aa22 100644 --- a/app.vue +++ b/app.vue @@ -77,24 +77,25 @@ const head = useLocaleHead({ addSeoAttributes: true, }); -const i18nLinks = computed(() => head.value.link?.map((e) => { +const i18nLinks = computed(() => head.value.link?.map((e: any) => { if (e.rel === 'alternate') { let href = e.href; + const url = parseURL(href); if (typeof e.hreflang === 'string' && (e.hreflang.includes('ja') || e.hreflang === 'x-default') && e.hreflang !== 'ja-KS') { - const url = parseURL(href); url.pathname = joinURL('/ja/', url.pathname); - href = cleanDoubleSlashes(withTrailingSlash(stringifyParsedURL(url))); - } else { - href = cleanDoubleSlashes(withTrailingSlash(href)); } + url.search = ''; + href = cleanDoubleSlashes(withTrailingSlash(stringifyParsedURL(url))); return { ...e, rel: e.rel, href, hreflang: e.hreflang }; } else if (e.rel === 'canonical' && locale.value === 'ja') { let href = e.href; const url = parseURL(href); url.pathname = joinURL('/ja/', url.pathname); + url.search = ''; href = cleanDoubleSlashes(withTrailingSlash(stringifyParsedURL(url))); return { ...e, rel: e.rel, href, hreflang: e.hreflang }; } + return e; }));