diff --git a/.eslintrc.json b/.eslintrc.json index 0b65a70..d261713 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,11 +3,7 @@ "browser": true, "es2021": true }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:solid/typescript" - ], + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:solid/typescript"], "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", diff --git a/.prettierrc.json b/.prettierrc.json index 071de61..f3d832f 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,5 @@ { - "printWidth": 100, + "printWidth": 120, "semi": true, "singleQuote": false, "tabWidth": 2, diff --git a/public/assets/js/detect-theme.js b/public/assets/js/detect-theme.js index 9d29c22..d34ae2c 100644 --- a/public/assets/js/detect-theme.js +++ b/public/assets/js/detect-theme.js @@ -15,10 +15,8 @@ window.theme = (() => { document.documentElement.setAttribute("data-theme", window.theme); /* Sync with OS theme */ -window - .matchMedia("(prefers-color-scheme: dark)") - .addEventListener("change", ({ matches: isDark }) => { - window.theme = isDark ? "dark" : "light"; - localStorage.setItem("theme", window.theme); - document.documentElement.setAttribute("data-theme", window.theme); - }); +window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", ({ matches: isDark }) => { + window.theme = isDark ? "dark" : "light"; + localStorage.setItem("theme", window.theme); + document.documentElement.setAttribute("data-theme", window.theme); +}); diff --git a/public/assets/js/load-code-highlight.js b/public/assets/js/load-code-highlight.js index 6abed24..9451820 100644 --- a/public/assets/js/load-code-highlight.js +++ b/public/assets/js/load-code-highlight.js @@ -42,9 +42,7 @@ if (window.theme) { $head.appendChild($dark); window.addEventListener("onthemetoggled", ({ detail: newTheme }) => toggleMedia(newTheme)); - window - .matchMedia("(prefers-color-scheme: dark)") - .addEventListener("change", ({ matches: isDark }) => { - return isDark ? toggleMedia("dark") : toggleMedia("light"); - }); + window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", ({ matches: isDark }) => { + return isDark ? toggleMedia("dark") : toggleMedia("light"); + }); } diff --git a/src/components/ArticleItem/ArticleItem.tsx b/src/components/ArticleItem/ArticleItem.tsx index a64d1b9..0c0e074 100644 --- a/src/components/ArticleItem/ArticleItem.tsx +++ b/src/components/ArticleItem/ArticleItem.tsx @@ -15,9 +15,9 @@ export const ArticleItem: Component = (props) => { return (

{props.data.title}

diff --git a/src/components/Header/NavToggle/NavToggle.tsx b/src/components/Header/NavToggle/NavToggle.tsx index f12ca34..712149c 100644 --- a/src/components/Header/NavToggle/NavToggle.tsx +++ b/src/components/Header/NavToggle/NavToggle.tsx @@ -4,25 +4,13 @@ import { createSignal, createEffect } from "solid-js"; import "./NavToggle.scss"; const MenuIcon: Component = () => ( - + ); const CloseIcon: Component = () => ( - + ); @@ -44,13 +32,7 @@ const NavToggle: Component = () => { }); return ( -
- + )} diff --git a/src/components/ThemeSwticher/ThemeSwitcher.tsx b/src/components/ThemeSwticher/ThemeSwitcher.tsx index d6dd099..a28c970 100644 --- a/src/components/ThemeSwticher/ThemeSwitcher.tsx +++ b/src/components/ThemeSwticher/ThemeSwitcher.tsx @@ -43,12 +43,10 @@ const ThemeSwitcher: Component = () => { if (window.theme) { setTheme(window.theme); /* Update theme state on changing OS theme */ - window - .matchMedia("(prefers-color-scheme: dark)") - .addEventListener("change", ({ matches: isDark }) => { - const theme = isDark ? "dark" : "light"; - setTheme(theme); - }); + window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", ({ matches: isDark }) => { + const theme = isDark ? "dark" : "light"; + setTheme(theme); + }); } }); diff --git a/src/config.ts b/src/config.ts index 1c0c6a8..4cec084 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,8 +1,7 @@ export const DEFAULT_LANGUAGE: LanguageKeys = "ru"; /* Show banner about website development */ -export const IS_SITE_UNDER_CONSTRUCTION = - import.meta.env.IS_SITE_UNDER_CONSTRUCTION === "true" ? true : false; +export const IS_SITE_UNDER_CONSTRUCTION = import.meta.env.IS_SITE_UNDER_CONSTRUCTION === "true" ? true : false; export const SITE_METADATA: SiteMetadataType = { title: "Sergey Yarkov", @@ -15,10 +14,19 @@ export const SITE_METADATA: SiteMetadataType = { telegramUrl: "https://t.me/sergeyyarkov", }, nav: [ - { key: "navigation.articles", url: "/articles/" }, - { key: "navigation.projects", url: "/projects/" }, + { + key: "navigation.articles", + url: "/articles/", + }, + { + key: "navigation.projects", + url: "/projects/", + }, { key: "navigation.about", url: "/about/" }, - { key: "navigation.contacts", url: "/contacts/" }, + { + key: "navigation.contacts", + url: "/contacts/", + }, ], projects: [ { @@ -113,11 +121,20 @@ export const SITE_METADATA: SiteMetadataType = { en: "Programming", }, list: [ - { icon: "nodejs", name: "Javascript/Typescript" }, - { icon: "language-c", name: "C Language" }, + { + icon: "nodejs", + name: "Javascript/Typescript", + }, + { + icon: "language-c", + name: "C Language", + }, { icon: "mysql", name: "SQL" }, { icon: "graphql", name: "GraphQL" }, - { icon: "avr", name: "AVR instruction set" }, + { + icon: "avr", + name: "AVR instruction set", + }, ], }, { @@ -142,7 +159,10 @@ export const SITE_METADATA: SiteMetadataType = { list: [ { icon: "nodejs", name: "Node.js" }, { icon: "docker", name: "Docker" }, - { icon: "git-branch", name: "Git/gitflow" }, + { + icon: "git-branch", + name: "Git/gitflow", + }, { icon: "sass", name: "SASS" }, { icon: "webpack", name: "Webpack" }, { icon: "vite", name: "Vite.js" }, @@ -154,7 +174,10 @@ export const SITE_METADATA: SiteMetadataType = { en: "Databases", }, list: [ - { icon: "postgresql", name: "PostgreSQL" }, + { + icon: "postgresql", + name: "PostgreSQL", + }, { icon: "mongodb", name: "MongoDB" }, { icon: "redis", name: "Redis" }, ], diff --git a/src/i18n/en/ui.ts b/src/i18n/en/ui.ts index 49e47f0..a140144 100644 --- a/src/i18n/en/ui.ts +++ b/src/i18n/en/ui.ts @@ -15,8 +15,7 @@ export default { /* Page descriptions */ "pageDescription.articles": "Technical articles, tutorials and various reference materials related to IT topics can be found here.", - "pageDescription.projects": - "A few of my main projects that have been developed and published in open access.", + "pageDescription.projects": "A few of my main projects that have been developed and published in open access.", "pageDescription.contacts": "Use the feedback form or write to me on social networks.", /* Navigation */ "navigation.articles": "Articles", diff --git a/src/i18n/ru/ui.ts b/src/i18n/ru/ui.ts index 8485f4e..f7ad02c 100644 --- a/src/i18n/ru/ui.ts +++ b/src/i18n/ru/ui.ts @@ -15,10 +15,8 @@ export default { /* Page descriptions */ "pageDescription.articles": "Технические статьи, туториалы и различные справочные материалы которые связаны с IT тематикой находятся здесь.", - "pageDescription.projects": - "Несколько моих основных проектов которые были разработаны и выложены в открытый доступ.", - "pageDescription.contacts": - "Воспользуйтесь формой обратной связи или напишите мне в социальные сети.", + "pageDescription.projects": "Несколько моих основных проектов которые были разработаны и выложены в открытый доступ.", + "pageDescription.contacts": "Воспользуйтесь формой обратной связи или напишите мне в социальные сети.", /* Navigation */ "navigation.articles": "Статьи", "navigation.projects": "Проекты", diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index f238ce0..0273a25 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -3,14 +3,9 @@ import * as utils from "@utils/url"; import { DEFAULT_LANGUAGE } from "@root/config"; import languages from "./languages"; -type TranslatedArticlesType = Record< - string, - Record> | Record ->; +type TranslatedArticlesType = Record> | Record>; -export function formatArticlesByLangs( - data: Record> -): TranslatedArticlesType { +export function formatArticlesByLangs(data: Record>): TranslatedArticlesType { const modules: TranslatedArticlesType = {}; for (const module of Object.values(data)) { @@ -38,20 +33,15 @@ function transformExports(modules: Record) { return translations; } -const translations = transformExports( - import.meta.glob("./*/ui.ts", { eager: true }) -); +const translations = transformExports(import.meta.glob("./*/ui.ts", { eager: true })); export function translate(key: UIDictionaryKeys, lang: LanguageKeys): string | undefined { - const string: string | undefined = - translations[lang]?.[key] || translations[DEFAULT_LANGUAGE][key]; + const string: string | undefined = translations[lang]?.[key] || translations[DEFAULT_LANGUAGE][key]; if (string === undefined) console.log(`Cannot find any string for translation key "${key}".`); return string; } -export function useTranslation( - Astro: Readonly -): (key: UIDictionaryKeys) => string | undefined { +export function useTranslation(Astro: Readonly): (key: UIDictionaryKeys) => string | undefined { const lang: LanguageKeys = utils.getLanguageFromURL(Astro.url.pathname) as LanguageKeys; return (key: UIDictionaryKeys) => translate(key, lang); } diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index 925c54a..7815d69 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -22,9 +22,7 @@ for (const key of Object.keys(articles)) { new Date(published_at).toLocaleDateString("en-CA") + `/${slug}/`, title, - description: `${description}${ - coverImage !== undefined ? `${title}` : "" - }`, + description: `${description}${coverImage !== undefined ? `${title}` : ""}`, pubDate: published_at, customData: `${lang}`, }); diff --git a/src/types/main.d.ts b/src/types/main.d.ts index eee38fa..b5af401 100644 --- a/src/types/main.d.ts +++ b/src/types/main.d.ts @@ -28,7 +28,10 @@ declare global { githubUrl: string; telegramUrl: string; }; - nav: Array<{ key: UIDictionaryKeys; url: string }>; + nav: Array<{ + key: UIDictionaryKeys; + url: string; + }>; projects: Array; skills: Array; }; @@ -57,7 +60,10 @@ declare global { type SkillsType = { title: Record; - list: Array<{ icon?: string | undefined; name: string }>; + list: Array<{ + icon?: string | undefined; + name: string; + }>; }; type ContactFieldsType = { diff --git a/src/utils/articles.ts b/src/utils/articles.ts index 5bf867b..7ea06ce 100644 --- a/src/utils/articles.ts +++ b/src/utils/articles.ts @@ -12,9 +12,7 @@ export const transformArticles = (articles: MDXInstance[]): Article })); export const sortArtcilesByDate = (articles: ArticleType[]): ArticleType[] => { - return articles.sort( - (a, b) => new Date(b.published_at).valueOf() - new Date(a.published_at).valueOf() - ); + return articles.sort((a, b) => new Date(b.published_at).valueOf() - new Date(a.published_at).valueOf()); }; /** @@ -33,10 +31,7 @@ export const formatToArticleBlocks = (articles: ArticleType[]): ArticleBlockType return blocks; }; -export const findArticlesBySearch = ( - search: string, - articles: ArticleBlockType -): ArticleBlockType => { +export const findArticlesBySearch = (search: string, articles: ArticleBlockType): ArticleBlockType => { const matched: Array = []; search = search.toLocaleLowerCase(); @@ -54,10 +49,7 @@ export const findArticlesBySearch = ( return formatToArticleBlocks(matched); }; -export const findArticlesByTags = ( - tags: string[], - articles: ArticleBlockType -): ArticleBlockType => { +export const findArticlesByTags = (tags: string[], articles: ArticleBlockType): ArticleBlockType => { const matched: Array = []; for (const year in articles) { diff --git a/src/utils/string.ts b/src/utils/string.ts index 4d0df9f..026d02a 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -7,7 +7,7 @@ export function isEmail(email: string): boolean { } export function isURL(url: string): boolean { - return new RegExp( - /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\\/~+#-]*[\w@?^=%&\\/~+#-])/ - ).test(url); + return new RegExp(/(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\\/~+#-]*[\w@?^=%&\\/~+#-])/).test( + url + ); }