Skip to content

Commit

Permalink
refact: add console.logs to avoid false warnings
Browse files Browse the repository at this point in the history
Known astro-lang issue => withastro/language-tools#476
  • Loading branch information
taverasmisael committed Dec 27, 2023
1 parent 8bb7500 commit 3337ee6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pages/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ if (!collectionName || collectionName !== "blog") {
return Astro.redirect(`/404?from=${slug}`);
}
const postFound = await getCollection(collectionName, ({ slug }) => slug.includes(name));
return postFound.length
? Astro.redirect(getEntryURL(collectionName, postFound[0].slug), 301 /* Moved Permanently */)
: Astro.redirect(`/404?from=${slug}`);
const knownPostURL = postFound.length ? getEntryURL(collectionName, postFound[0].slug) : null;
// KI: To supress `astro:check` warning -- https://github.com/withastro/language-tools/issues/476
console.log(`knownPostURL: ${knownPostURL}`);
return knownPostURL ? Astro.redirect(knownPostURL, 301 /* Moved Permanently */) : Astro.redirect(`/404?from=${slug}`);
---
2 changes: 2 additions & 0 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const headerLang = Astro.request.headers.get("accept-language");
if (headerLang) {
const browserLang = headerLang.split(",")[0].split("-")[0];
const lang = isSupportedLang(browserLang) ? browserLang : DEFAULT_LOCALE;
// KI: To supress `astro:check` warning -- https://github.com/withastro/language-tools/issues/476
console.log(`Redirecting to ${lang}`)
return Astro.redirect(`/${lang}`);
}
Expand Down

0 comments on commit 3337ee6

Please sign in to comment.