mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 10:29:21 +03:00
fix: fixed language changing on article post page
This commit is contained in:
parent
a8be51891d
commit
8f76011018
@ -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>
|
||||
))
|
||||
}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user