+
-::github{repo="saicaca/fuwari"}
+# 👋 hiya, i'm DevComp
-> ### Sources of images used in this site
-> - [Unsplash](https://unsplash.com/)
-> - [星と少女](https://www.pixiv.net/artworks/108916539) by [Stella](https://www.pixiv.net/users/93273965)
-> - [Rabbit - v1.4 Showcase](https://civitai.com/posts/586908) by [Rabbit_YourMajesty](https://civitai.com/user/Rabbit_YourMajesty)
\ No newline at end of file
+
+
+
+
+![Systems](https://skillicons.dev/icons?i=rust,go,java,lua,bash,neovim,linux,docker&perline=10)
+![Web](https://skillicons.dev/icons?i=html,css,js,ts,prisma,mysql,nextjs,vercel&perline=10)
+
+## Contact
+
+If you would like to get in touch with me, reach out to me via:
+
+- Discord - DevComp
+- Twitter - [@DevComp_](https://twitter.com/DevComp_)
+- Email - [mailto:hi@devcomp.xyz](hi@devcomp.xyz)
+
+[![Hits](https://hits-app.vercel.app/hits?url=https://github.com/CompeyDev&bgLeft=cba6f7&bgRight=1e1e2e&label=visits)](https://hits-app.vercel.app/)
diff --git a/src/i18n/i18nKey.ts b/src/i18n/i18nKey.ts
index e43eb93..5129602 100644
--- a/src/i18n/i18nKey.ts
+++ b/src/i18n/i18nKey.ts
@@ -1,37 +1,37 @@
enum I18nKey {
- home = 'home',
- about = 'about',
- archive = 'archive',
- search = 'search',
+ home = "home",
+ about = "about",
+ archive = "archive",
+ search = "search",
- tags = 'tags',
- categories = 'categories',
- recentPosts = 'recentPosts',
+ tags = "tags",
+ categories = "categories",
+ recentPosts = "recentPosts",
- comments = 'comments',
+ comments = "comments",
- untitled = 'untitled',
- uncategorized = 'uncategorized',
- noTags = 'noTags',
+ untitled = "untitled",
+ uncategorized = "uncategorized",
+ noTags = "noTags",
- wordCount = 'wordCount',
- wordsCount = 'wordsCount',
- minuteCount = 'minuteCount',
- minutesCount = 'minutesCount',
- postCount = 'postCount',
- postsCount = 'postsCount',
+ wordCount = "wordCount",
+ wordsCount = "wordsCount",
+ minuteCount = "minuteCount",
+ minutesCount = "minutesCount",
+ postCount = "postCount",
+ postsCount = "postsCount",
- themeColor = 'themeColor',
+ themeColor = "themeColor",
- lightMode = 'lightMode',
- darkMode = 'darkMode',
- systemMode = 'systemMode',
+ lightMode = "lightMode",
+ darkMode = "darkMode",
+ systemMode = "systemMode",
- more = 'more',
+ more = "more",
- author = 'author',
- publishedAt = 'publishedAt',
- license = 'license',
+ author = "author",
+ publishedAt = "publishedAt",
+ license = "license",
}
-export default I18nKey
+export default I18nKey;
diff --git a/src/i18n/languages/en.ts b/src/i18n/languages/en.ts
index 8aeaae5..28bf1a0 100644
--- a/src/i18n/languages/en.ts
+++ b/src/i18n/languages/en.ts
@@ -1,38 +1,38 @@
-import Key from '../i18nKey'
-import type { Translation } from '../translation'
+import Key from "../i18nKey";
+import type { Translation } from "../translation";
export const en: Translation = {
- [Key.home]: 'Home',
- [Key.about]: 'About',
- [Key.archive]: 'Archive',
- [Key.search]: 'Search',
+ [Key.home]: "Home",
+ [Key.about]: "About",
+ [Key.archive]: "Archive",
+ [Key.search]: "Search",
- [Key.tags]: 'Tags',
- [Key.categories]: 'Categories',
- [Key.recentPosts]: 'Recent Posts',
+ [Key.tags]: "Tags",
+ [Key.categories]: "Categories",
+ [Key.recentPosts]: "Recent Posts",
- [Key.comments]: 'Comments',
+ [Key.comments]: "Comments",
- [Key.untitled]: 'Untitled',
- [Key.uncategorized]: 'Uncategorized',
- [Key.noTags]: 'No Tags',
+ [Key.untitled]: "Untitled",
+ [Key.uncategorized]: "Uncategorized",
+ [Key.noTags]: "No Tags",
- [Key.wordCount]: 'word',
- [Key.wordsCount]: 'words',
- [Key.minuteCount]: 'minute',
- [Key.minutesCount]: 'minutes',
- [Key.postCount]: 'post',
- [Key.postsCount]: 'posts',
+ [Key.wordCount]: "word",
+ [Key.wordsCount]: "words",
+ [Key.minuteCount]: "minute",
+ [Key.minutesCount]: "minutes",
+ [Key.postCount]: "post",
+ [Key.postsCount]: "posts",
- [Key.themeColor]: 'Theme Color',
+ [Key.themeColor]: "Theme Color",
- [Key.lightMode]: 'Light',
- [Key.darkMode]: 'Dark',
- [Key.systemMode]: 'System',
+ [Key.lightMode]: "Light",
+ [Key.darkMode]: "Dark",
+ [Key.systemMode]: "System",
- [Key.more]: 'More',
+ [Key.more]: "More",
- [Key.author]: 'Author',
- [Key.publishedAt]: 'Published at',
- [Key.license]: 'License',
-}
+ [Key.author]: "Author",
+ [Key.publishedAt]: "Published at",
+ [Key.license]: "License",
+};
diff --git a/src/i18n/languages/ja.ts b/src/i18n/languages/ja.ts
index 251f052..48de3f5 100644
--- a/src/i18n/languages/ja.ts
+++ b/src/i18n/languages/ja.ts
@@ -1,38 +1,38 @@
-import Key from '../i18nKey'
-import type { Translation } from '../translation'
+import Key from "../i18nKey";
+import type { Translation } from "../translation";
export const ja: Translation = {
- [Key.home]: 'Home',
- [Key.about]: 'About',
- [Key.archive]: 'Archive',
- [Key.search]: '検索',
+ [Key.home]: "Home",
+ [Key.about]: "About",
+ [Key.archive]: "Archive",
+ [Key.search]: "検索",
- [Key.tags]: 'タグ',
- [Key.categories]: 'カテゴリ',
- [Key.recentPosts]: '最近の投稿',
+ [Key.tags]: "タグ",
+ [Key.categories]: "カテゴリ",
+ [Key.recentPosts]: "最近の投稿",
- [Key.comments]: 'コメント',
+ [Key.comments]: "コメント",
- [Key.untitled]: 'タイトルなし',
- [Key.uncategorized]: 'カテゴリなし',
- [Key.noTags]: 'タグなし',
+ [Key.untitled]: "タイトルなし",
+ [Key.uncategorized]: "カテゴリなし",
+ [Key.noTags]: "タグなし",
- [Key.wordCount]: '文字',
- [Key.wordsCount]: '文字',
- [Key.minuteCount]: '分',
- [Key.minutesCount]: '分',
- [Key.postCount]: '件の投稿',
- [Key.postsCount]: '件の投稿',
+ [Key.wordCount]: "文字",
+ [Key.wordsCount]: "文字",
+ [Key.minuteCount]: "分",
+ [Key.minutesCount]: "分",
+ [Key.postCount]: "件の投稿",
+ [Key.postsCount]: "件の投稿",
- [Key.themeColor]: 'テーマカラー',
+ [Key.themeColor]: "テーマカラー",
- [Key.lightMode]: 'ライト',
- [Key.darkMode]: 'ダーク',
- [Key.systemMode]: 'システム',
+ [Key.lightMode]: "ライト",
+ [Key.darkMode]: "ダーク",
+ [Key.systemMode]: "システム",
- [Key.more]: 'もっと',
+ [Key.more]: "もっと",
- [Key.author]: '作者',
- [Key.publishedAt]: '公開日',
- [Key.license]: 'ライセンス',
-}
+ [Key.author]: "作者",
+ [Key.publishedAt]: "公開日",
+ [Key.license]: "ライセンス",
+};
diff --git a/src/i18n/languages/zh_CN.ts b/src/i18n/languages/zh_CN.ts
index 32c006e..f95fd3c 100644
--- a/src/i18n/languages/zh_CN.ts
+++ b/src/i18n/languages/zh_CN.ts
@@ -1,38 +1,38 @@
-import Key from '../i18nKey'
-import type { Translation } from '../translation'
+import Key from "../i18nKey";
+import type { Translation } from "../translation";
export const zh_CN: Translation = {
- [Key.home]: '主页',
- [Key.about]: '关于',
- [Key.archive]: '归档',
- [Key.search]: '搜索',
+ [Key.home]: "主页",
+ [Key.about]: "关于",
+ [Key.archive]: "归档",
+ [Key.search]: "搜索",
- [Key.tags]: '标签',
- [Key.categories]: '分类',
- [Key.recentPosts]: '最新文章',
+ [Key.tags]: "标签",
+ [Key.categories]: "分类",
+ [Key.recentPosts]: "最新文章",
- [Key.comments]: '评论',
+ [Key.comments]: "评论",
- [Key.untitled]: '无标题',
- [Key.uncategorized]: '未分类',
- [Key.noTags]: '无标签',
+ [Key.untitled]: "无标题",
+ [Key.uncategorized]: "未分类",
+ [Key.noTags]: "无标签",
- [Key.wordCount]: '字',
- [Key.wordsCount]: '字',
- [Key.minuteCount]: '分钟',
- [Key.minutesCount]: '分钟',
- [Key.postCount]: '篇文章',
- [Key.postsCount]: '篇文章',
+ [Key.wordCount]: "字",
+ [Key.wordsCount]: "字",
+ [Key.minuteCount]: "分钟",
+ [Key.minutesCount]: "分钟",
+ [Key.postCount]: "篇文章",
+ [Key.postsCount]: "篇文章",
- [Key.themeColor]: '主题色',
+ [Key.themeColor]: "主题色",
- [Key.lightMode]: '亮色',
- [Key.darkMode]: '暗色',
- [Key.systemMode]: '跟随系统',
+ [Key.lightMode]: "亮色",
+ [Key.darkMode]: "暗色",
+ [Key.systemMode]: "跟随系统",
- [Key.more]: '更多',
+ [Key.more]: "更多",
- [Key.author]: '作者',
- [Key.publishedAt]: '发布于',
- [Key.license]: '许可协议',
-}
+ [Key.author]: "作者",
+ [Key.publishedAt]: "发布于",
+ [Key.license]: "许可协议",
+};
diff --git a/src/i18n/languages/zh_TW.ts b/src/i18n/languages/zh_TW.ts
index b5719d4..0c8a2e5 100644
--- a/src/i18n/languages/zh_TW.ts
+++ b/src/i18n/languages/zh_TW.ts
@@ -1,38 +1,38 @@
-import Key from '../i18nKey'
-import type { Translation } from '../translation'
+import Key from "../i18nKey";
+import type { Translation } from "../translation";
export const zh_TW: Translation = {
- [Key.home]: '首頁',
- [Key.about]: '關於',
- [Key.archive]: '彙整',
- [Key.search]: '搜尋',
+ [Key.home]: "首頁",
+ [Key.about]: "關於",
+ [Key.archive]: "彙整",
+ [Key.search]: "搜尋",
- [Key.tags]: '標籤',
- [Key.categories]: '分類',
- [Key.recentPosts]: '最新文章',
+ [Key.tags]: "標籤",
+ [Key.categories]: "分類",
+ [Key.recentPosts]: "最新文章",
- [Key.comments]: '評論',
+ [Key.comments]: "評論",
- [Key.untitled]: '無標題',
- [Key.uncategorized]: '未分類',
- [Key.noTags]: '無標籤',
+ [Key.untitled]: "無標題",
+ [Key.uncategorized]: "未分類",
+ [Key.noTags]: "無標籤",
- [Key.wordCount]: '字',
- [Key.wordsCount]: '字',
- [Key.minuteCount]: '分鐘',
- [Key.minutesCount]: '分鐘',
- [Key.postCount]: '篇文章',
- [Key.postsCount]: '篇文章',
+ [Key.wordCount]: "字",
+ [Key.wordsCount]: "字",
+ [Key.minuteCount]: "分鐘",
+ [Key.minutesCount]: "分鐘",
+ [Key.postCount]: "篇文章",
+ [Key.postsCount]: "篇文章",
- [Key.themeColor]: '主題色',
+ [Key.themeColor]: "主題色",
- [Key.lightMode]: '亮色',
- [Key.darkMode]: '暗色',
- [Key.systemMode]: '跟隨系統',
+ [Key.lightMode]: "亮色",
+ [Key.darkMode]: "暗色",
+ [Key.systemMode]: "跟隨系統",
- [Key.more]: '更多',
+ [Key.more]: "更多",
- [Key.author]: '作者',
- [Key.publishedAt]: '發佈於',
- [Key.license]: '許可協議',
-}
+ [Key.author]: "作者",
+ [Key.publishedAt]: "發佈於",
+ [Key.license]: "許可協議",
+};
diff --git a/src/i18n/translation.ts b/src/i18n/translation.ts
index 89fe2a6..7f28340 100644
--- a/src/i18n/translation.ts
+++ b/src/i18n/translation.ts
@@ -1,15 +1,15 @@
-import { siteConfig } from '../config'
-import type I18nKey from './i18nKey'
-import { en } from './languages/en'
-import { ja } from './languages/ja'
-import { zh_CN } from './languages/zh_CN'
-import { zh_TW } from './languages/zh_TW'
+import { siteConfig } from "../config";
+import type I18nKey from "./i18nKey";
+import { en } from "./languages/en";
+import { ja } from "./languages/ja";
+import { zh_CN } from "./languages/zh_CN";
+import { zh_TW } from "./languages/zh_TW";
export type Translation = {
- [K in I18nKey]: string
-}
+ [K in I18nKey]: string;
+};
-const defaultTranslation = en
+const defaultTranslation = en;
const map: { [key: string]: Translation } = {
en: en,
@@ -20,13 +20,13 @@ const map: { [key: string]: Translation } = {
zh_tw: zh_TW,
ja: ja,
ja_jp: ja,
-}
+};
export function getTranslation(lang: string): Translation {
- return map[lang.toLowerCase()] || defaultTranslation
+ return map[lang.toLowerCase()] || defaultTranslation;
}
export function i18n(key: I18nKey): string {
- const lang = siteConfig.lang || 'en'
- return getTranslation(lang)[key]
+ const lang = siteConfig.lang || "en";
+ return getTranslation(lang)[key];
}
diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro
index f1837a4..0eb6deb 100644
--- a/src/layouts/Layout.astro
+++ b/src/layouts/Layout.astro
@@ -1,57 +1,62 @@
---
import GlobalStyles from "@components/GlobalStyles.astro";
-import '@fontsource/roboto/400.css';
-import '@fontsource/roboto/500.css';
-import '@fontsource/roboto/700.css';
+import "@fontsource/roboto/400.css";
+import "@fontsource/roboto/500.css";
+import "@fontsource/roboto/700.css";
import ImageWrapper from "@components/misc/ImageWrapper.astro";
-import {pathsEqual} from "@utils/url-utils";
+import { profileConfig, siteConfig } from "@/config";
import ConfigCarrier from "@components/ConfigCarrier.astro";
-import {profileConfig, siteConfig} from "@/config";
-import {Favicon} from "../types/config";
-import {defaultFavicons} from "../constants/icon";
-import {LIGHT_MODE, DARK_MODE, AUTO_MODE, DEFAULT_THEME} from "../constants/constants";
-import {url} from "../utils/url-utils";
+import { pathsEqual } from "@utils/url-utils";
+import {
+ AUTO_MODE,
+ DARK_MODE,
+ DEFAULT_THEME,
+ LIGHT_MODE,
+} from "../constants/constants";
+import { defaultFavicons } from "../constants/icon";
+import type { Favicon } from "../types/config";
+import { url } from "../utils/url-utils";
interface Props {
- title: string;
- banner: string;
- description?: string;
+ title: string;
+ banner: string;
+ description?: string;
}
let { title, banner, description } = Astro.props;
-const isHomePage = pathsEqual(Astro.url.pathname, '/');
+const isHomePage = pathsEqual(Astro.url.pathname, "/");
const testPathName = Astro.url.pathname;
const anim = {
- old: {
- name: 'fadeIn',
- duration: '4s',
- easing: 'linear',
- fillMode: 'forwards',
- mixBlendMode: 'normal',
- },
- new: {
- name: 'fadeOut',
- duration: '4s',
- easing: 'linear',
- fillMode: 'backwards',
- mixBlendMode: 'normal',
- }
+ old: {
+ name: "fadeIn",
+ duration: "4s",
+ easing: "linear",
+ fillMode: "forwards",
+ mixBlendMode: "normal",
+ },
+ new: {
+ name: "fadeOut",
+ duration: "4s",
+ easing: "linear",
+ fillMode: "backwards",
+ mixBlendMode: "normal",
+ },
};
const myFade = {
- forwards: anim,
- backwards: anim,
+ forwards: anim,
+ backwards: anim,
};
// defines global css variables
// why doing this in Layout instead of GlobalStyles: https://github.com/withastro/astro/issues/6728#issuecomment-1502203757
const configHue = siteConfig.themeColor.hue;
-if (!banner || typeof banner !== 'string' || banner.trim() === '') {
- banner = siteConfig.banner.src;
+if (!banner || typeof banner !== "string" || banner.trim() === "") {
+ banner = siteConfig.banner.src;
}
// TODO don't use post cover as banner for now
@@ -59,17 +64,17 @@ banner = siteConfig.banner.src;
const enableBanner = siteConfig.banner.enable;
-let pageTitle;
+let pageTitle: string;
if (title) {
- pageTitle = `${title} - ${siteConfig.title}`;
+ pageTitle = `${title} - ${siteConfig.title}`;
} else {
- pageTitle = `${siteConfig.title} - ${siteConfig.subtitle}`;
+ pageTitle = `${siteConfig.title} - ${siteConfig.subtitle}`;
}
-const favicons: Favicon[] = siteConfig.favicon.length > 0 ? siteConfig.favicon : defaultFavicons
-
-const siteLang = siteConfig.lang.replace('_', '-')
+const favicons: Favicon[] =
+ siteConfig.favicon.length > 0 ? siteConfig.favicon : defaultFavicons;
+const siteLang = siteConfig.lang.replace("_", "-");
---
diff --git a/src/layouts/MainGridLayout.astro b/src/layouts/MainGridLayout.astro
index e687d79..8da230a 100644
--- a/src/layouts/MainGridLayout.astro
+++ b/src/layouts/MainGridLayout.astro
@@ -1,22 +1,21 @@
---
-import Layout from "./Layout.astro";
-import Navbar from "@components/Navbar.astro";
-import SideBar from "@components/widget/SideBar.astro";
-import {pathsEqual} from "@utils/url-utils";
+import { siteConfig } from "@/config";
import Footer from "@components/Footer.astro";
+import Navbar from "@components/Navbar.astro";
import BackToTop from "@components/control/BackToTop.astro";
-import {siteConfig} from "@/config";
+import SideBar from "@components/widget/SideBar.astro";
+import { pathsEqual } from "@utils/url-utils";
+import Layout from "./Layout.astro";
interface Props {
- title: string;
- banner?: string;
- description?: string;
+ title: string;
+ banner?: string;
+ description?: string;
}
-const { title, banner, description } = Astro.props
-const isHomePage = pathsEqual(Astro.url.pathname, '/')
-const enableBanner = siteConfig.banner.enable
-
+const { title, banner, description } = Astro.props;
+const isHomePage = pathsEqual(Astro.url.pathname, "/");
+const enableBanner = siteConfig.banner.enable;
---
diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro
index d370537..c678395 100644
--- a/src/pages/[...page].astro
+++ b/src/pages/[...page].astro
@@ -1,21 +1,20 @@
---
-import MainGridLayout from "../layouts/MainGridLayout.astro";
import PostCard from "../components/PostCard.astro";
-import Pagination from "../components/control/Pagination.astro";
-import {getSortedPosts} from "../utils/content-utils";
-import {getPostUrlBySlug} from "../utils/url-utils";
-import {PAGE_SIZE} from "../constants/constants";
import PostPage from "../components/PostPage.astro";
+import Pagination from "../components/control/Pagination.astro";
+import { PAGE_SIZE } from "../constants/constants";
+import MainGridLayout from "../layouts/MainGridLayout.astro";
+import { getSortedPosts } from "../utils/content-utils";
+import { getPostUrlBySlug } from "../utils/url-utils";
export async function getStaticPaths({ paginate }) {
- const allBlogPosts = await getSortedPosts();
- return paginate(allBlogPosts, { pageSize: PAGE_SIZE });
+ const allBlogPosts = await getSortedPosts();
+ return paginate(allBlogPosts, { pageSize: PAGE_SIZE });
}
-const {page} = Astro.props;
+const { page } = Astro.props;
const len = page.data.length;
-
---
diff --git a/src/pages/about.astro b/src/pages/about.astro
index 476c631..cacb952 100644
--- a/src/pages/about.astro
+++ b/src/pages/about.astro
@@ -2,15 +2,14 @@
import MainGridLayout from "../layouts/MainGridLayout.astro";
-import { getEntry } from 'astro:content'
-import {i18n} from "../i18n/translation";
-import I18nKey from "../i18n/i18nKey";
+import { getEntry } from "astro:content";
import Markdown from "@components/misc/Markdown.astro";
+import I18nKey from "../i18n/i18nKey";
+import { i18n } from "../i18n/translation";
-const aboutPost = await getEntry('spec', 'about')
-
-const { Content } = await aboutPost.render()
+const aboutPost = await getEntry("spec", "about");
+const { Content } = await aboutPost.render();
---
diff --git a/src/pages/archive/category/[category].astro b/src/pages/archive/category/[category].astro
index 88aa0d3..cd140b2 100644
--- a/src/pages/archive/category/[category].astro
+++ b/src/pages/archive/category/[category].astro
@@ -1,23 +1,22 @@
---
-import {getCategoryList, getSortedPosts} from "@utils/content-utils";
-import MainGridLayout from "@layouts/MainGridLayout.astro";
import ArchivePanel from "@components/ArchivePanel.astro";
-import {i18n} from "@i18n/translation";
import I18nKey from "@i18n/i18nKey";
+import { i18n } from "@i18n/translation";
+import MainGridLayout from "@layouts/MainGridLayout.astro";
+import { getCategoryList, getSortedPosts } from "@utils/content-utils";
export async function getStaticPaths() {
- const categories = await getCategoryList();
- return categories.map(category => {
- return {
- params: {
- category: category.name
- }
- }
- });
+ const categories = await getCategoryList();
+ return categories.map(category => {
+ return {
+ params: {
+ category: category.name,
+ },
+ };
+ });
}
const { category } = Astro.params;
-
---
diff --git a/src/pages/archive/category/uncategorized.astro b/src/pages/archive/category/uncategorized.astro
index d580146..2ba29aa 100644
--- a/src/pages/archive/category/uncategorized.astro
+++ b/src/pages/archive/category/uncategorized.astro
@@ -1,9 +1,9 @@
---
-import MainGridLayout from "@layouts/MainGridLayout.astro";
import ArchivePanel from "@components/ArchivePanel.astro";
-import {i18n} from "@i18n/translation";
+import { UNCATEGORIZED } from "@constants/constants";
import I18nKey from "@i18n/i18nKey";
-import {UNCATEGORIZED} from "@constants/constants";
+import { i18n } from "@i18n/translation";
+import MainGridLayout from "@layouts/MainGridLayout.astro";
---
diff --git a/src/pages/archive/index.astro b/src/pages/archive/index.astro
index cf0d419..b277936 100644
--- a/src/pages/archive/index.astro
+++ b/src/pages/archive/index.astro
@@ -1,9 +1,9 @@
---
import { getCollection, getEntry } from "astro:content";
-import MainGridLayout from "@layouts/MainGridLayout.astro";
import ArchivePanel from "@components/ArchivePanel.astro";
-import {i18n} from "@i18n/translation";
import I18nKey from "@i18n/i18nKey";
+import { i18n } from "@i18n/translation";
+import MainGridLayout from "@layouts/MainGridLayout.astro";
---
diff --git a/src/pages/archive/tag/[tag].astro b/src/pages/archive/tag/[tag].astro
index ce132a4..71f949e 100644
--- a/src/pages/archive/tag/[tag].astro
+++ b/src/pages/archive/tag/[tag].astro
@@ -1,32 +1,30 @@
---
-import {getSortedPosts} from "@utils/content-utils";
-import MainGridLayout from "@layouts/MainGridLayout.astro";
import ArchivePanel from "@components/ArchivePanel.astro";
-import {i18n} from "@i18n/translation";
import I18nKey from "@i18n/i18nKey";
-
+import { i18n } from "@i18n/translation";
+import MainGridLayout from "@layouts/MainGridLayout.astro";
+import { getSortedPosts } from "@utils/content-utils";
export async function getStaticPaths() {
- let posts = await getSortedPosts()
+ const posts = await getSortedPosts();
- const allTags = posts.reduce((acc, post) => {
- post.data.tags.forEach(tag => acc.add(tag));
- return acc;
- }, new Set());
+ const allTags = posts.reduce((acc, post) => {
+ post.data.tags?.forEach(tag => acc.add(tag));
+ return acc;
+ }, new Set());
- const allTagsArray = Array.from(allTags);
+ const allTagsArray = Array.from(allTags);
- return allTagsArray.map(tag => {
- return {
- params: {
- tag: tag
- }
- }
- });
+ return allTagsArray.map(tag => {
+ return {
+ params: {
+ tag: tag,
+ },
+ };
+ });
}
-const { tag } = Astro.params;
-
+const { tag } = Astro.params as { tag: string };
---
diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro
index 20bbe8c..556900c 100644
--- a/src/pages/posts/[...slug].astro
+++ b/src/pages/posts/[...slug].astro
@@ -1,26 +1,27 @@
---
-import { getCollection } from 'astro:content';
-import MainGridLayout from "@layouts/MainGridLayout.astro";
-import ImageWrapper from "../../components/misc/ImageWrapper.astro";
-import {Icon} from "astro-icon/components";
-import PostMetadata from "../../components/PostMeta.astro";
-import {i18n} from "@i18n/translation";
-import I18nKey from "@i18n/i18nKey";
-import {getDir, getPostUrlBySlug} from "@utils/url-utils";
-import License from "@components/misc/License.astro";
-import {licenseConfig} from "src/config";
-import Markdown from "@components/misc/Markdown.astro";
import path from "path";
-import {profileConfig} from "../../config";
-import {formatDateToYYYYMMDD} from "../../utils/date-utils";
+import { getCollection } from "astro:content";
+import License from "@components/misc/License.astro";
+import Markdown from "@components/misc/Markdown.astro";
+import I18nKey from "@i18n/i18nKey";
+import { i18n } from "@i18n/translation";
+import MainGridLayout from "@layouts/MainGridLayout.astro";
+import { getDir, getPostUrlBySlug } from "@utils/url-utils";
+import { Icon } from "astro-icon/components";
+import { licenseConfig } from "src/config";
+import PostMetadata from "../../components/PostMeta.astro";
+import ImageWrapper from "../../components/misc/ImageWrapper.astro";
+import { profileConfig } from "../../config";
+import { formatDateToYYYYMMDD } from "../../utils/date-utils";
export async function getStaticPaths() {
- const blogEntries = await getCollection('posts', ({ data }) => {
- return import.meta.env.PROD ? data.draft !== true : true;
- });
- return blogEntries.map(entry => ({
- params: { slug: entry.slug }, props: { entry },
- }));
+ const blogEntries = await getCollection("posts", ({ data }) => {
+ return import.meta.env.PROD ? data.draft !== true : true;
+ });
+ return blogEntries.map(entry => ({
+ params: { slug: entry.slug },
+ props: { entry },
+ }));
}
const { entry } = Astro.props;
@@ -29,20 +30,19 @@ const { Content } = await entry.render();
const { remarkPluginFrontmatter } = await entry.render();
const jsonLd = {
- "@context": "https://schema.org",
- "@type": "BlogPosting",
- "headline": entry.data.title,
- "description": entry.data.description || entry.data.title,
- "keywords": entry.data.tags,
- "author": {
- "@type": "Person",
- "name": profileConfig.name,
- "url": Astro.site
- },
- "datePublished": formatDateToYYYYMMDD(entry.data.published),
- // TODO include cover image here
-}
-
+ "@context": "https://schema.org",
+ "@type": "BlogPosting",
+ headline: entry.data.title,
+ description: entry.data.description || entry.data.title,
+ keywords: entry.data.tags,
+ author: {
+ "@type": "Person",
+ name: profileConfig.name,
+ url: Astro.site,
+ },
+ datePublished: formatDateToYYYYMMDD(entry.data.published),
+ // TODO include cover image here
+};
---
diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts
index 9649a44..bfb5261 100644
--- a/src/pages/robots.txt.ts
+++ b/src/pages/robots.txt.ts
@@ -1,16 +1,16 @@
-import type { APIRoute } from 'astro';
+import type { APIRoute } from "astro";
const robotsTxt = `
User-agent: *
Allow: /
-Sitemap: ${new URL('sitemap-index.xml', import.meta.env.SITE).href}
+Sitemap: ${new URL("sitemap-index.xml", import.meta.env.SITE).href}
`.trim();
export const GET: APIRoute = () => {
return new Response(robotsTxt, {
headers: {
- 'Content-Type': 'text/plain; charset=utf-8',
+ "Content-Type": "text/plain; charset=utf-8",
},
});
-};
\ No newline at end of file
+};
diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts
index d4e9872..782bed7 100644
--- a/src/pages/rss.xml.ts
+++ b/src/pages/rss.xml.ts
@@ -1,25 +1,25 @@
-import rss from '@astrojs/rss';
-import {siteConfig} from '@/config';
-import { getCollection } from 'astro:content';
-import sanitizeHtml from 'sanitize-html';
-import MarkdownIt from 'markdown-it';
+import { getCollection } from "astro:content";
+import { siteConfig } from "@/config";
+import rss from "@astrojs/rss";
+import MarkdownIt from "markdown-it";
+import sanitizeHtml from "sanitize-html";
const parser = new MarkdownIt();
export async function GET(context: any) {
- const blog = await getCollection('posts');
+ const blog = await getCollection("posts");
return rss({
title: siteConfig.title,
- description: siteConfig.subtitle || 'No description',
+ description: siteConfig.subtitle || "No description",
site: context.site,
- items: blog.map((post) => ({
- title: post.data.title,
- pubDate: post.data.published,
- description: post.data.description,
- link: `/posts/${post.slug}/`,
- content: sanitizeHtml(parser.render(post.body), {
- allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img'])
- }),
- })),
+ items: blog.map(post => ({
+ title: post.data.title,
+ pubDate: post.data.published,
+ description: post.data.description,
+ link: `/posts/${post.slug}/`,
+ content: sanitizeHtml(parser.render(post.body), {
+ allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]),
+ }),
+ })),
customData: `${siteConfig.lang}`,
});
-}
\ No newline at end of file
+}
diff --git a/src/plugins/rehype-component-admonition.mjs b/src/plugins/rehype-component-admonition.mjs
index 895d735..23621ea 100644
--- a/src/plugins/rehype-component-admonition.mjs
+++ b/src/plugins/rehype-component-admonition.mjs
@@ -1,5 +1,5 @@
///
-import { h } from 'hastscript'
+import { h } from "hastscript";
/**
* Creates an admonition component.
@@ -11,21 +11,22 @@ import { h } from 'hastscript'
* @returns {import('mdast').Parent} The created admonition component.
*/
export function AdmonitionComponent(properties, children, type) {
- if (!Array.isArray(children) || children.length === 0)
- return h("div",
- { class: 'hidden' },
- 'Invalid admonition directive. (Admonition directives must be of block type ":::note{name="name"} :::")'
- );
+ if (!Array.isArray(children) || children.length === 0)
+ return h(
+ "div",
+ { class: "hidden" },
+ 'Invalid admonition directive. (Admonition directives must be of block type ":::note{name="name"} :::")',
+ );
- let label = null
- if (properties && properties['has-directive-label']) {
- label = children[0]; // The first child is the label
+ let label = null;
+ if (properties?.["has-directive-label"]) {
+ label = children[0]; // The first child is the label
children = children.slice(1);
- label.tagName = "div"; // Change the tag to
+ label.tagName = "div"; // Change the tag
to
}
- return h(`blockquote`,
- { class: `admonition bdm-${type}` },
- [ h("span", { class: `bdm-title` }, label ? label : type.toUpperCase()), ...children]
- );
-}
\ No newline at end of file
+ return h("blockquote", { class: `admonition bdm-${type}` }, [
+ h("span", { class: "bdm-title" }, label ? label : type.toUpperCase()),
+ ...children,
+ ]);
+}
diff --git a/src/plugins/rehype-component-github-card.mjs b/src/plugins/rehype-component-github-card.mjs
index 70737c5..3b5da84 100644
--- a/src/plugins/rehype-component-github-card.mjs
+++ b/src/plugins/rehype-component-github-card.mjs
@@ -1,5 +1,5 @@
///
-import { h } from 'hastscript'
+import { h } from "hastscript";
/**
* Creates a GitHub Card component.
@@ -10,68 +10,49 @@ import { h } from 'hastscript'
* @returns {import('mdast').Parent} The created GitHub Card component.
*/
export function GithubCardComponent(properties, children) {
- if (Array.isArray(children) && children.length !== 0)
- return h("div",
- { class: 'hidden' },
- ['Invalid directive. ("github" directive must be leaf type "::github{repo="owner/repo"}")']
- );
+ if (Array.isArray(children) && children.length !== 0)
+ return h("div", { class: "hidden" }, [
+ 'Invalid directive. ("github" directive must be leaf type "::github{repo="owner/repo"}")',
+ ]);
- if (!properties.repo || !properties.repo.includes("/"))
- return h("div",
- { class: 'hidden' },
- 'Invalid repository. ("repo" attributte must be in the format "owner/repo")'
- );
+ if (!properties.repo || !properties.repo.includes("/"))
+ return h(
+ "div",
+ { class: "hidden" },
+ 'Invalid repository. ("repo" attributte must be in the format "owner/repo")',
+ );
const repo = properties.repo;
- const cardUuid = `GC${Math.random().toString(36).slice(-6)}` // Collisions are not important
+ const cardUuid = `GC${Math.random().toString(36).slice(-6)}`; // Collisions are not important
- const nAvatar = h(
- `div#${cardUuid}-avatar`,
- { class: "gc-avatar"},
- )
+ const nAvatar = h(`div#${cardUuid}-avatar`, { class: "gc-avatar" });
const nLanguage = h(
`span#${cardUuid}-language`,
{ class: "gc-language" },
- "Waiting..."
- )
+ "Waiting...",
+ );
- const nTitle = h(
- `div`,
- { class: "gc-titlebar" },
- [
- h("div", { class: "gc-titlebar-left"}, [
- h("div", { class: "gc-owner" }, [
- nAvatar,
- h("div", { class: "gc-user" }, repo.split("/")[0] ),
- ]),
- h("div", { class: "gc-divider" }, "/" ),
- h("div", { class: "gc-repo" }, repo.split("/")[1] )
+ const nTitle = h("div", { class: "gc-titlebar" }, [
+ h("div", { class: "gc-titlebar-left" }, [
+ h("div", { class: "gc-owner" }, [
+ nAvatar,
+ h("div", { class: "gc-user" }, repo.split("/")[0]),
]),
- h("div", { class: "github-logo"})
- ]
- )
+ h("div", { class: "gc-divider" }, "/"),
+ h("div", { class: "gc-repo" }, repo.split("/")[1]),
+ ]),
+ h("div", { class: "github-logo" }),
+ ]);
const nDescription = h(
`div#${cardUuid}-description`,
{ class: "gc-description" },
- "Waiting for api.github.com..."
- )
+ "Waiting for api.github.com...",
+ );
- const nStars = h(
- `div#${cardUuid}-stars`,
- { class: "gc-stars" },
- "00K"
- )
- const nForks = h(
- `div#${cardUuid}-forks`,
- { class: "gc-forks" },
- "0K"
- )
- const nLicense = h(
- `div#${cardUuid}-license`,
- { class: "gc-license" },
- "0K"
- )
+ const nStars = h(`div#${cardUuid}-stars`, { class: "gc-stars" }, "00K");
+ const nForks = h(`div#${cardUuid}-forks`, { class: "gc-forks" }, "0K");
+ const nLicense = h(`div#${cardUuid}-license`, { class: "gc-license" }, "0K");
const nScript = h(
`script#${cardUuid}-script`,
@@ -98,22 +79,22 @@ export function GithubCardComponent(properties, children) {
c.classList.add("fetch-error");
console.warn("[GITHUB-CARD] (Error) Loading card for ${repo} | ${cardUuid}.")
})
- `
- )
+ `,
+ );
- return h(`a#${cardUuid}-card`,
- { class: "card-github fetch-waiting no-styling",
+ return h(
+ `a#${cardUuid}-card`,
+ {
+ class: "card-github fetch-waiting no-styling",
href: `https://github.com/${repo}`,
- target: '_blank',
- repo },
+ target: "_blank",
+ repo,
+ },
[
nTitle,
nDescription,
- h("div",
- { class: "gc-infobar" },
- [nStars, nForks, nLicense, nLanguage]
- ),
- nScript
- ]
+ h("div", { class: "gc-infobar" }, [nStars, nForks, nLicense, nLanguage]),
+ nScript,
+ ],
);
-}
\ No newline at end of file
+}
diff --git a/src/plugins/remark-directive-rehype.js b/src/plugins/remark-directive-rehype.js
index 0552a11..e16a673 100644
--- a/src/plugins/remark-directive-rehype.js
+++ b/src/plugins/remark-directive-rehype.js
@@ -1,27 +1,33 @@
-// biome-ignore lint/suspicious/noShadowRestrictedNames:
-import { h } from 'hastscript';
-import {visit} from 'unist-util-visit'
+import { h } from "hastscript";
+import { visit } from "unist-util-visit";
export function parseDirectiveNode() {
- return (tree, { data }) => {
- visit(tree, function (node) {
- if (
- node.type === 'containerDirective' ||
- node.type === 'leafDirective' ||
- node.type === 'textDirective'
- ) {
- const data = node.data || (node.data = {})
- node.attributes = node.attributes || {}
- if (node.children.length > 0 && node.children[0].data && node.children[0].data.directiveLabel) {
- // Add a flag to the node to indicate that it has a directive label
- node.attributes['has-directive-label'] = true
- }
- const hast = h(node.name, node.attributes)
+ return (tree, { data }) => {
+ visit(tree, node => {
+ if (
+ node.type === "containerDirective" ||
+ node.type === "leafDirective" ||
+ node.type === "textDirective"
+ ) {
+ if (!node.data) {
+ node.data = {};
+ }
- data.hName = hast.tagName
- data.hProperties = hast.properties
- }
- })
- }
+ const data = node.data;
+ node.attributes = node.attributes || {};
+ if (
+ node.children.length > 0 &&
+ node.children[0].data &&
+ node.children[0].data.directiveLabel
+ ) {
+ // Add a flag to the node to indicate that it has a directive label
+ node.attributes["has-directive-label"] = true;
+ }
+ const hast = h(node.name, node.attributes);
+
+ data.hName = hast.tagName;
+ data.hProperties = hast.properties;
+ }
+ });
+ };
}
-
diff --git a/src/plugins/remark-reading-time.mjs b/src/plugins/remark-reading-time.mjs
index fd171a6..4443d70 100644
--- a/src/plugins/remark-reading-time.mjs
+++ b/src/plugins/remark-reading-time.mjs
@@ -1,15 +1,15 @@
// biome-ignore lint/suspicious/noShadowRestrictedNames:
-import { toString } from 'mdast-util-to-string'
-import getReadingTime from 'reading-time'
+import { toString } from "mdast-util-to-string";
+import getReadingTime from "reading-time";
export function remarkReadingTime() {
return (tree, { data }) => {
- const textOnPage = toString(tree)
- const readingTime = getReadingTime(textOnPage)
+ const textOnPage = toString(tree);
+ const readingTime = getReadingTime(textOnPage);
data.astro.frontmatter.minutes = Math.max(
1,
Math.round(readingTime.minutes),
- )
- data.astro.frontmatter.words = readingTime.words
- }
+ );
+ data.astro.frontmatter.words = readingTime.words;
+ };
}
diff --git a/src/types/config.ts b/src/types/config.ts
index 0e7aff9..3196136 100644
--- a/src/types/config.ts
+++ b/src/types/config.ts
@@ -1,29 +1,29 @@
-import type { LIGHT_MODE, DARK_MODE, AUTO_MODE } from "@constants/constants"
+import type { AUTO_MODE, DARK_MODE, LIGHT_MODE } from "@constants/constants";
export type SiteConfig = {
- title: string
- subtitle: string
+ title: string;
+ subtitle: string;
- lang: string
+ lang: string;
themeColor: {
- hue: number
- fixed: boolean
- }
+ hue: number;
+ fixed: boolean;
+ };
banner: {
- enable: boolean
- src: string
- position?: string
- }
+ enable: boolean;
+ src: string;
+ position?: string;
+ };
- favicon: Favicon[]
-}
+ favicon: Favicon[];
+};
export type Favicon = {
- src: string
- theme?: 'light' | 'dark'
- sizes?: string
-}
+ src: string;
+ theme?: "light" | "dark";
+ sizes?: string;
+};
export enum LinkPreset {
Home = 0,
@@ -32,30 +32,33 @@ export enum LinkPreset {
}
export type NavBarLink = {
- name: string
- url: string
- external?: boolean
-}
+ name: string;
+ url: string;
+ external?: boolean;
+};
export type NavBarConfig = {
- links: (NavBarLink | LinkPreset)[]
-}
+ links: (NavBarLink | LinkPreset)[];
+};
export type ProfileConfig = {
- avatar?: string
- name: string
- bio?: string
+ avatar?: string;
+ name: string;
+ bio?: string;
links: {
- name: string
- url: string
- icon: string
- }[]
-}
+ name: string;
+ url: string;
+ icon: string;
+ }[];
+};
export type LicenseConfig = {
- enable: boolean
- name: string
- url: string
-}
+ enable: boolean;
+ name: string;
+ url: string;
+};
-export type LIGHT_DARK_MODE = typeof LIGHT_MODE | typeof DARK_MODE | typeof AUTO_MODE
+export type LIGHT_DARK_MODE =
+ | typeof LIGHT_MODE
+ | typeof DARK_MODE
+ | typeof AUTO_MODE;
diff --git a/src/utils/content-utils.ts b/src/utils/content-utils.ts
index 023c177..3fb1be9 100644
--- a/src/utils/content-utils.ts
+++ b/src/utils/content-utils.ts
@@ -1,83 +1,83 @@
-import I18nKey from '@i18n/i18nKey'
-import { i18n } from '@i18n/translation'
-import { getCollection } from 'astro:content'
+import { getCollection } from "astro:content";
+import I18nKey from "@i18n/i18nKey";
+import { i18n } from "@i18n/translation";
export async function getSortedPosts() {
- const allBlogPosts = await getCollection('posts', ({ data }) => {
- return import.meta.env.PROD ? data.draft !== true : true
- })
+ const allBlogPosts = await getCollection("posts", ({ data }) => {
+ return import.meta.env.PROD ? data.draft !== true : true;
+ });
const sorted = allBlogPosts.sort((a, b) => {
- const dateA = new Date(a.data.published)
- const dateB = new Date(b.data.published)
- return dateA > dateB ? -1 : 1
- })
+ const dateA = new Date(a.data.published);
+ const dateB = new Date(b.data.published);
+ return dateA > dateB ? -1 : 1;
+ });
for (let i = 1; i < sorted.length; i++) {
- sorted[i].data.nextSlug = sorted[i - 1].slug
- sorted[i].data.nextTitle = sorted[i - 1].data.title
+ sorted[i].data.nextSlug = sorted[i - 1].slug;
+ sorted[i].data.nextTitle = sorted[i - 1].data.title;
}
for (let i = 0; i < sorted.length - 1; i++) {
- sorted[i].data.prevSlug = sorted[i + 1].slug
- sorted[i].data.prevTitle = sorted[i + 1].data.title
+ sorted[i].data.prevSlug = sorted[i + 1].slug;
+ sorted[i].data.prevTitle = sorted[i + 1].data.title;
}
- return sorted
+ return sorted;
}
export type Tag = {
- name: string
- count: number
-}
+ name: string;
+ count: number;
+};
export async function getTagList(): Promise {
- const allBlogPosts = await getCollection('posts', ({ data }) => {
- return import.meta.env.PROD ? data.draft !== true : true
- })
+ const allBlogPosts = await getCollection("posts", ({ data }) => {
+ return import.meta.env.PROD ? data.draft !== true : true;
+ });
- const countMap: { [key: string]: number } = {}
+ const countMap: { [key: string]: number } = {};
allBlogPosts.map(post => {
post.data.tags.map((tag: string) => {
- if (!countMap[tag]) countMap[tag] = 0
- countMap[tag]++
- })
- })
+ if (!countMap[tag]) countMap[tag] = 0;
+ countMap[tag]++;
+ });
+ });
// sort tags
const keys: string[] = Object.keys(countMap).sort((a, b) => {
- return a.toLowerCase().localeCompare(b.toLowerCase())
- })
+ return a.toLowerCase().localeCompare(b.toLowerCase());
+ });
- return keys.map(key => ({ name: key, count: countMap[key] }))
+ return keys.map(key => ({ name: key, count: countMap[key] }));
}
export type Category = {
- name: string
- count: number
-}
+ name: string;
+ count: number;
+};
export async function getCategoryList(): Promise {
- const allBlogPosts = await getCollection('posts', ({ data }) => {
- return import.meta.env.PROD ? data.draft !== true : true
- })
- const count: { [key: string]: number } = {}
+ const allBlogPosts = await getCollection("posts", ({ data }) => {
+ return import.meta.env.PROD ? data.draft !== true : true;
+ });
+ const count: { [key: string]: number } = {};
allBlogPosts.map(post => {
if (!post.data.category) {
- const ucKey = i18n(I18nKey.uncategorized)
- count[ucKey] = count[ucKey] ? count[ucKey] + 1 : 1
- return
+ const ucKey = i18n(I18nKey.uncategorized);
+ count[ucKey] = count[ucKey] ? count[ucKey] + 1 : 1;
+ return;
}
count[post.data.category] = count[post.data.category]
? count[post.data.category] + 1
- : 1
- })
+ : 1;
+ });
const lst = Object.keys(count).sort((a, b) => {
- return a.toLowerCase().localeCompare(b.toLowerCase())
- })
+ return a.toLowerCase().localeCompare(b.toLowerCase());
+ });
- const ret: Category[] = []
+ const ret: Category[] = [];
for (const c of lst) {
- ret.push({ name: c, count: count[c] })
+ ret.push({ name: c, count: count[c] });
}
- return ret
+ return ret;
}
diff --git a/src/utils/date-utils.ts b/src/utils/date-utils.ts
index 8267ea9..b62fbb9 100644
--- a/src/utils/date-utils.ts
+++ b/src/utils/date-utils.ts
@@ -1,3 +1,3 @@
export function formatDateToYYYYMMDD(date: Date): string {
- return date.toISOString().substring(0, 10)
+ return date.toISOString().substring(0, 10);
}
diff --git a/src/utils/setting-utils.ts b/src/utils/setting-utils.ts
index 6471901..fa0860b 100644
--- a/src/utils/setting-utils.ts
+++ b/src/utils/setting-utils.ts
@@ -1,50 +1,54 @@
-import {AUTO_MODE, DARK_MODE, DEFAULT_THEME, LIGHT_MODE} from "@constants/constants.ts";
-import type { LIGHT_DARK_MODE } from '@/types/config'
+import type { LIGHT_DARK_MODE } from "@/types/config";
+import {
+ AUTO_MODE,
+ DARK_MODE,
+ DEFAULT_THEME,
+ LIGHT_MODE,
+} from "@constants/constants.ts";
export function getDefaultHue(): number {
- const fallback = '250'
- const configCarrier = document.getElementById('config-carrier')
- return parseInt(configCarrier?.dataset.hue || fallback)
+ const fallback = "250";
+ const configCarrier = document.getElementById("config-carrier");
+ return Number.parseInt(configCarrier?.dataset.hue || fallback);
}
export function getHue(): number {
- const stored = localStorage.getItem('hue')
- return stored ? parseInt(stored) : getDefaultHue()
+ const stored = localStorage.getItem("hue");
+ return stored ? Number.parseInt(stored) : getDefaultHue();
}
export function setHue(hue: number): void {
- localStorage.setItem('hue', String(hue))
- const r = document.querySelector(':root')
+ localStorage.setItem("hue", String(hue));
+ const r = document.querySelector(":root");
if (!r) {
- return
+ return;
}
- r.style.setProperty('--hue', hue)
+ r.style.setProperty("--hue", hue);
}
-
export function applyThemeToDocument(theme: LIGHT_DARK_MODE) {
switch (theme) {
case LIGHT_MODE:
- document.documentElement.classList.remove('dark')
- break
+ document.documentElement.classList.remove("dark");
+ break;
case DARK_MODE:
- document.documentElement.classList.add('dark')
- break
+ document.documentElement.classList.add("dark");
+ break;
case AUTO_MODE:
- if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
- document.documentElement.classList.add('dark')
+ if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
+ document.documentElement.classList.add("dark");
} else {
- document.documentElement.classList.remove('dark')
+ document.documentElement.classList.remove("dark");
}
- break
+ break;
}
}
export function setTheme(theme: LIGHT_DARK_MODE): void {
- localStorage.setItem('theme', theme)
- applyThemeToDocument(theme)
+ localStorage.setItem("theme", theme);
+ applyThemeToDocument(theme);
}
export function getStoredTheme(): LIGHT_DARK_MODE {
- return localStorage.getItem('theme') as LIGHT_DARK_MODE || DEFAULT_THEME
+ return (localStorage.getItem("theme") as LIGHT_DARK_MODE) || DEFAULT_THEME;
}
diff --git a/src/utils/url-utils.ts b/src/utils/url-utils.ts
index 6b8e545..f2fa8f5 100644
--- a/src/utils/url-utils.ts
+++ b/src/utils/url-utils.ts
@@ -1,37 +1,37 @@
-import i18nKey from '@i18n/i18nKey'
-import { i18n } from '@i18n/translation'
+import i18nKey from "@i18n/i18nKey";
+import { i18n } from "@i18n/translation";
export function pathsEqual(path1: string, path2: string) {
- const normalizedPath1 = path1.replace(/^\/|\/$/g, '').toLowerCase()
- const normalizedPath2 = path2.replace(/^\/|\/$/g, '').toLowerCase()
- return normalizedPath1 === normalizedPath2
+ const normalizedPath1 = path1.replace(/^\/|\/$/g, "").toLowerCase();
+ const normalizedPath2 = path2.replace(/^\/|\/$/g, "").toLowerCase();
+ return normalizedPath1 === normalizedPath2;
}
function joinUrl(...parts: string[]): string {
- const joined = parts.join('/')
- return joined.replace(/\/+/g, '/');
+ const joined = parts.join("/");
+ return joined.replace(/\/+/g, "/");
}
export function getPostUrlBySlug(slug: string): string | null {
- if (!slug) return null
- return url(`/posts/${slug}/`)
+ if (!slug) return null;
+ return url(`/posts/${slug}/`);
}
export function getCategoryUrl(category: string): string | null {
- if (!category) return null
+ if (!category) return null;
if (category === i18n(i18nKey.uncategorized))
- return url('/archive/category/uncategorized/')
- return url(`/archive/category/${category}/`)
+ return url("/archive/category/uncategorized/");
+ return url(`/archive/category/${category}/`);
}
export function getDir(path: string): string {
- const lastSlashIndex = path.lastIndexOf('/')
+ const lastSlashIndex = path.lastIndexOf("/");
if (lastSlashIndex < 0) {
- return '/'
+ return "/";
}
- return path.substring(0, lastSlashIndex + 1)
+ return path.substring(0, lastSlashIndex + 1);
}
export function url(path: string) {
- return joinUrl('', import.meta.env.BASE_URL, path)
-}
\ No newline at end of file
+ return joinUrl("", import.meta.env.BASE_URL, path);
+}