mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 10:29:21 +03:00
refactor: refactored about page
This commit is contained in:
parent
c67fdb982b
commit
ed83799d94
@ -1,6 +1,9 @@
|
|||||||
import type { AstroGlobal, MDXInstance } from "astro";
|
import type { AstroGlobal, MDXInstance } from "astro";
|
||||||
|
|
||||||
import { formatArticlesByLangs } from "@i18n/utils";
|
import { formatArticlesByLangs } from "@i18n/utils";
|
||||||
|
import { getLanguageFromURL } from "@root/utils";
|
||||||
|
import { DEFAULT_LANGUAGE } from "@root/config";
|
||||||
|
|
||||||
import * as utils from "@utils/index";
|
import * as utils from "@utils/index";
|
||||||
|
|
||||||
export function fetchTranslatedArticles(Astro: Readonly<AstroGlobal>): MDXInstance<ArticleType>[] {
|
export function fetchTranslatedArticles(Astro: Readonly<AstroGlobal>): MDXInstance<ArticleType>[] {
|
||||||
@ -42,3 +45,16 @@ export function fetchTranslatedArticles(Astro: Readonly<AstroGlobal>): MDXInstan
|
|||||||
|
|
||||||
return utils.getPublishedArticles(articles);
|
return utils.getPublishedArticles(articles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchAboutMe(Astro: Readonly<AstroGlobal>): Promise<MDXInstance<{}>> {
|
||||||
|
const lang = getLanguageFromURL(Astro.url.pathname);
|
||||||
|
let markdown: MDXInstance<{}> | undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
markdown = (await import(`../../content/about/${lang}/index.mdx`)) as MDXInstance<{}>;
|
||||||
|
} catch (error) {
|
||||||
|
markdown = (await import(`../../content/about/${DEFAULT_LANGUAGE}/index.mdx`)) as MDXInstance<{}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return markdown;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,26 +1,17 @@
|
|||||||
---
|
---
|
||||||
import type { MDXInstance } from "astro";
|
import { SITE_METADATA } from "@root/config";
|
||||||
|
|
||||||
import { DEFAULT_LANGUAGE, SITE_METADATA } from "@root/config";
|
|
||||||
import PageLayout from "@layouts/default.astro";
|
import PageLayout from "@layouts/default.astro";
|
||||||
|
import { getLanguageFromURL } from "@root/utils";
|
||||||
|
import { useTranslation } from "@i18n/utils";
|
||||||
|
import * as API from "@root/lib/api";
|
||||||
import PageHeading from "@components/PageHeading";
|
import PageHeading from "@components/PageHeading";
|
||||||
import SkillsList from "@components/SkillsList";
|
import SkillsList from "@components/SkillsList";
|
||||||
import SkillsBlock from "@components/SkillsBlock";
|
import SkillsBlock from "@components/SkillsBlock";
|
||||||
|
|
||||||
import ArticleContent from "@components/ArticleContent";
|
import ArticleContent from "@components/ArticleContent";
|
||||||
import { getLanguageFromURL } from "@root/utils";
|
|
||||||
import { useTranslation } from "@i18n/utils";
|
|
||||||
|
|
||||||
const lang = getLanguageFromURL(Astro.url.pathname);
|
const lang = getLanguageFromURL(Astro.url.pathname);
|
||||||
const t = useTranslation(Astro);
|
const t = useTranslation(Astro);
|
||||||
let markdown: MDXInstance<{}> | undefined;
|
const data = await API.fetchAboutMe(Astro);
|
||||||
|
|
||||||
try {
|
|
||||||
markdown = (await import(`../../content/about/${lang}/index.mdx`)) as MDXInstance<{}>;
|
|
||||||
} catch (error) {
|
|
||||||
markdown = (await import(`../../content/about/${DEFAULT_LANGUAGE}/index.mdx`)) as MDXInstance<{}>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { skills } = SITE_METADATA;
|
const { skills } = SITE_METADATA;
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -28,7 +19,7 @@ const { skills } = SITE_METADATA;
|
|||||||
<PageHeading heading={t("pageTitle.about")} />
|
<PageHeading heading={t("pageTitle.about")} />
|
||||||
<section>
|
<section>
|
||||||
<ArticleContent>
|
<ArticleContent>
|
||||||
{markdown && <markdown.Content />}
|
{data && <data.Content />}
|
||||||
</ArticleContent>
|
</ArticleContent>
|
||||||
<SkillsList>
|
<SkillsList>
|
||||||
{skills.map((block) => <SkillsBlock data={block} />)}
|
{skills.map((block) => <SkillsBlock data={block} />)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user