fix: fixed language changing on article post page

This commit is contained in:
Sergey Yarkov 2022-08-17 15:01:45 +03:00
parent a8be51891d
commit 8f76011018
2 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import { createDateFormatter } from "@root/utils";
import { Image } from "@astrojs/image/components";
import ArticleComments from "@components/ArticleComments";
import "./ArticlePost.scss";
import TranslatedLink from "../TranslatedLink";
export type Props = {
data: ArticleType;
@ -20,7 +21,7 @@ const { title, tags, author, published_at } = data;
{
tags.map((tag) => (
<li>
<a href={`/articles/?tags=${tag.toLocaleLowerCase()}`}>{`${tag}${tags.at(-1) === tag ? "" : ","}`}</a>
<TranslatedLink to={`/articles/?tags=${tag.toLocaleLowerCase()}`}>{`${tag}${tags.at(-1) === tag ? "" : ","}`}</TranslatedLink>
</li>
))
}

View File

@ -52,6 +52,12 @@ const lang = getLanguageFromURL(Astro.url.pathname);
const pathname = window.location.pathname;
const url = newLang === DEFAULT_LANGUAGE ? pathname.slice(3) : `${newLang}${pathname}`;
/* Move user to articles page with new language */
if (window.location.pathname.includes("/blog/")) {
window.location.pathname = `${newLang === DEFAULT_LANGUAGE ? "" : newLang + "/"}` + "articles/";
return;
}
window.location.pathname = url;
};