From 37cb82ccd5a382623effee2205df5ad4c4ac0b22 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Wed, 3 Aug 2022 18:30:20 +0300 Subject: [PATCH] refactor: moved pages to templates --- src/pages/404.astro | 9 ++------- src/pages/about.astro | 23 ++--------------------- src/pages/articles.astro | 23 ++--------------------- src/pages/contacts.astro | 11 ++--------- src/pages/index.astro | 25 ++----------------------- src/pages/projects.astro | 15 ++------------- src/templates/About.astro | 24 ++++++++++++++++++++++++ src/templates/Articles.astro | 24 ++++++++++++++++++++++++ src/templates/Contacts.astro | 12 ++++++++++++ src/templates/Home.astro | 26 ++++++++++++++++++++++++++ src/templates/NotFound.astro | 10 ++++++++++ src/templates/Projects.astro | 16 ++++++++++++++++ 12 files changed, 124 insertions(+), 94 deletions(-) create mode 100644 src/templates/About.astro create mode 100644 src/templates/Articles.astro create mode 100644 src/templates/Contacts.astro create mode 100644 src/templates/Home.astro create mode 100644 src/templates/NotFound.astro create mode 100644 src/templates/Projects.astro diff --git a/src/pages/404.astro b/src/pages/404.astro index d12a21c..fa0c686 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -1,10 +1,5 @@ --- - import PageLayout from '@layouts/default.astro' +import NotFound from '@root/templates/NotFound.astro'; --- - -
-

404

-

Страницу которую вы пытаетесь найти не существует.

-
-
\ No newline at end of file + diff --git a/src/pages/about.astro b/src/pages/about.astro index fb93f21..7d6b876 100644 --- a/src/pages/about.astro +++ b/src/pages/about.astro @@ -1,24 +1,5 @@ --- -import { SITE_METADATA } from '@root/config'; -import PageLayout from '@layouts/default.astro'; -import SkillsList from '@components/SkillsList'; -import SkillsBlock from '@components/SkillsBlock'; - -// TODO: import content based on user ui language -import * as data from '../../content/about/ru/index.md'; -import ArticleContent from '@components/ArticleContent'; - -const { skills } = SITE_METADATA; -const { Content } = data; +import About from '@root/templates/About.astro'; --- - -
- - - - - {skills.map((block) => )} - -
-
+ diff --git a/src/pages/articles.astro b/src/pages/articles.astro index 8f2974e..c37dc98 100644 --- a/src/pages/articles.astro +++ b/src/pages/articles.astro @@ -1,24 +1,5 @@ --- -import PageLayout from '@layouts/default.astro'; -import ArticlesList from '@components/ArticlesList'; -import { transformArticles, formatToArticleBlocks } from '@utils/articles'; - -const articles = await Astro.glob('../../content/articles/**/*.md'); -const tags = new Set(articles.map((article) => article.frontmatter.tags).flat()); +import Articles from '@root/templates/Articles.astro'; --- - -
- -
-
+ diff --git a/src/pages/contacts.astro b/src/pages/contacts.astro index 82caea4..1d07417 100644 --- a/src/pages/contacts.astro +++ b/src/pages/contacts.astro @@ -1,12 +1,5 @@ --- -import PageLayout from '@layouts/default.astro'; -import ContactForm from '@components/ContactForm'; -import ContactsList from '@components/ContactsList'; +import Contacts from '@root/templates/Contacts.astro'; --- - -
- - -
-
+ diff --git a/src/pages/index.astro b/src/pages/index.astro index 50e9e06..3371b69 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,26 +1,5 @@ --- -import * as utils from '@utils/index'; -import PageLayout from '@layouts/default.astro'; -import RecentArticles from '@components/RecentArticles'; -import { Splash, SplashHeading, SplashLinks, Link } from '@components/Splash'; - -const data = await Astro.glob('../../content/articles/**/*.md'); -const articles = utils.transformArticles(data); +import Home from '@root/templates/Home.astro'; --- - - - -
-

Hello, I'am Sergey

-

Fullstack web-developer & freelancer

-
-

Я занимаюсь разработкой веб-сайтов и веб-приложений разной сложности, а также публикую различные статьи и туториалы на разные IT темы.

-
- - обо мне - написать мне - -
- -
+ diff --git a/src/pages/projects.astro b/src/pages/projects.astro index 03f8ae5..89b26e8 100644 --- a/src/pages/projects.astro +++ b/src/pages/projects.astro @@ -1,16 +1,5 @@ --- -import { SITE_METADATA } from '@root/config'; -import PageLayout from '@layouts/default.astro'; -import ProjectsList from '@components/ProjectsList'; -import ProjectItem from '@components/ProjectItem'; - -const { projects } = SITE_METADATA; +import Projects from '@root/templates/Projects.astro'; --- - -
- - {projects.map((project) => )} - -
-
+ diff --git a/src/templates/About.astro b/src/templates/About.astro new file mode 100644 index 0000000..fb93f21 --- /dev/null +++ b/src/templates/About.astro @@ -0,0 +1,24 @@ +--- +import { SITE_METADATA } from '@root/config'; +import PageLayout from '@layouts/default.astro'; +import SkillsList from '@components/SkillsList'; +import SkillsBlock from '@components/SkillsBlock'; + +// TODO: import content based on user ui language +import * as data from '../../content/about/ru/index.md'; +import ArticleContent from '@components/ArticleContent'; + +const { skills } = SITE_METADATA; +const { Content } = data; +--- + + +
+ + + + + {skills.map((block) => )} + +
+
diff --git a/src/templates/Articles.astro b/src/templates/Articles.astro new file mode 100644 index 0000000..85bce3c --- /dev/null +++ b/src/templates/Articles.astro @@ -0,0 +1,24 @@ +--- +import PageLayout from '@layouts/default.astro'; +import ArticlesList from '@components/ArticlesList'; +import { transformArticles, formatToArticleBlocks } from '@utils/articles'; + +const articles = await Astro.glob('../../content/articles/**/*.md'); +const tags = new Set(articles.map((article) => article.frontmatter.tags).flat()); +--- + + +
+ +
+
diff --git a/src/templates/Contacts.astro b/src/templates/Contacts.astro new file mode 100644 index 0000000..2f022ac --- /dev/null +++ b/src/templates/Contacts.astro @@ -0,0 +1,12 @@ +--- +import PageLayout from '@layouts/default.astro'; +import ContactForm from '@components/ContactForm'; +import ContactsList from '@components/ContactsList'; +--- + + +
+ + +
+
diff --git a/src/templates/Home.astro b/src/templates/Home.astro new file mode 100644 index 0000000..50e9e06 --- /dev/null +++ b/src/templates/Home.astro @@ -0,0 +1,26 @@ +--- +import * as utils from '@utils/index'; +import PageLayout from '@layouts/default.astro'; +import RecentArticles from '@components/RecentArticles'; +import { Splash, SplashHeading, SplashLinks, Link } from '@components/Splash'; + +const data = await Astro.glob('../../content/articles/**/*.md'); +const articles = utils.transformArticles(data); +--- + + + + +
+

Hello, I'am Sergey

+

Fullstack web-developer & freelancer

+
+

Я занимаюсь разработкой веб-сайтов и веб-приложений разной сложности, а также публикую различные статьи и туториалы на разные IT темы.

+
+ + обо мне + написать мне + +
+ +
diff --git a/src/templates/NotFound.astro b/src/templates/NotFound.astro new file mode 100644 index 0000000..7e74675 --- /dev/null +++ b/src/templates/NotFound.astro @@ -0,0 +1,10 @@ +--- +import PageLayout from '@layouts/default.astro'; +--- + + +
+

404

+

Страницу которую вы пытаетесь найти не существует.

+
+
diff --git a/src/templates/Projects.astro b/src/templates/Projects.astro new file mode 100644 index 0000000..1dddd87 --- /dev/null +++ b/src/templates/Projects.astro @@ -0,0 +1,16 @@ +--- +import { SITE_METADATA } from '@root/config'; +import PageLayout from '@layouts/default.astro'; +import ProjectsList from '@components/ProjectsList'; +import ProjectItem from '@components/ProjectItem'; + +const { projects } = SITE_METADATA; +--- + + +
+ + {projects.map((project) => )} + +
+