mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 10:29:21 +03:00
fix
This commit is contained in:
parent
946d52fd7c
commit
3f42730659
@ -17,9 +17,7 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const modules = import.meta.glob<MDXInstance<ArticleType>>("../../content/articles/**/*.mdx", {
|
const modules = import.meta.glob<MDXInstance<ArticleType>>("../../content/articles/**/*.mdx", { eager: true });
|
||||||
eager: true,
|
|
||||||
});
|
|
||||||
const entries = Object.keys(modules).map((key) => [key, key.split("/").slice(6)[0]]);
|
const entries = Object.keys(modules).map((key) => [key, key.split("/").slice(6)[0]]);
|
||||||
const formatted = formatArticlesByLangs(modules);
|
const formatted = formatArticlesByLangs(modules);
|
||||||
|
|
||||||
@ -28,14 +26,9 @@ export async function getStaticPaths() {
|
|||||||
const article = modules[key];
|
const article = modules[key];
|
||||||
const dirName = key.split("/").at(-3);
|
const dirName = key.split("/").at(-3);
|
||||||
const published_at = new Date(article.frontmatter.published_at).toLocaleDateString("en-CA");
|
const published_at = new Date(article.frontmatter.published_at).toLocaleDateString("en-CA");
|
||||||
const slug = `${lang !== DEFAULT_LANGUAGE ? `${lang}/` : ""}blog/${published_at}/${
|
const slug = `${lang !== DEFAULT_LANGUAGE ? `${lang}/` : ""}blog/${published_at}/${article.frontmatter.slug}`;
|
||||||
article.frontmatter.slug
|
|
||||||
}`;
|
|
||||||
|
|
||||||
return {
|
return { params: { slug }, props: { article, alternateLangs: Object.keys(formatted[dirName]) } };
|
||||||
params: { slug },
|
|
||||||
props: { article, alternateLangs: Object.keys(formatted[dirName]) },
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
.filter(({ props: { article } }) => !article.frontmatter.draft);
|
.filter(({ props: { article } }) => !article.frontmatter.draft);
|
||||||
}
|
}
|
||||||
@ -49,6 +42,20 @@ const { pathname } = Astro.url;
|
|||||||
---
|
---
|
||||||
|
|
||||||
<ArticleLayout lang={siteLang} content={frontmatter} canonicalUrl={canonicalUrl.href}>
|
<ArticleLayout lang={siteLang} content={frontmatter} canonicalUrl={canonicalUrl.href}>
|
||||||
|
{
|
||||||
|
alternateLangs.length > 1 && (
|
||||||
|
<div class="languages-available">
|
||||||
|
{t("article.availableOn")}:
|
||||||
|
{alternateLangs
|
||||||
|
.filter((lang) => lang !== siteLang)
|
||||||
|
.map((lang) => (
|
||||||
|
<a href={DEFAULT_LANGUAGE === lang ? `/${pathname.split("/").slice(2).join("/")}` : `/${lang}${pathname}`}>
|
||||||
|
{languages[lang]}
|
||||||
|
</a>
|
||||||
|
))
|
||||||
|
.reduce((prev, curr) => [prev, ", ", curr])}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
<Content />
|
<Content />
|
||||||
</ArticleLayout>
|
</ArticleLayout>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user