From 286b050fa8d0c07b62e679450922b5e647703475 Mon Sep 17 00:00:00 2001 From: Katsuyuki Karasawa <4ranci0ne@gmail.com> Date: Tue, 8 Apr 2025 23:08:31 +0900 Subject: [PATCH] format all code (#386) --- biome.json | 2 +- src/components/ArchivePanel.astro | 88 +++++------ src/components/ConfigCarrier.astro | 2 +- src/components/Footer.astro | 6 +- src/components/LightDarkSwitch.svelte | 80 +++++----- src/components/Navbar.astro | 34 ++-- src/components/PostCard.astro | 70 ++++----- src/components/PostMeta.astro | 35 +++-- src/components/PostPage.astro | 10 +- src/components/Search.svelte | 116 +++++++------- src/components/control/BackToTop.astro | 2 +- src/components/control/ButtonLink.astro | 8 +- src/components/control/ButtonTag.astro | 10 +- src/components/control/Pagination.astro | 64 ++++---- src/components/misc/ImageWrapper.astro | 64 ++++---- src/components/misc/License.astro | 28 ++-- src/components/misc/Markdown.astro | 8 +- src/components/widget/Categories.astro | 28 ++-- src/components/widget/DisplaySettings.svelte | 16 +- src/components/widget/NavMenuPanel.astro | 10 +- src/components/widget/Profile.astro | 10 +- src/components/widget/SideBar.astro | 15 +- src/components/widget/TOC.astro | 24 +-- src/components/widget/Tags.astro | 26 ++-- src/components/widget/WidgetLayout.astro | 22 +-- src/config.ts | 147 +++++++++--------- src/constants/constants.ts | 22 +-- src/constants/icon.ts | 84 +++++----- src/constants/link-presets.ts | 32 ++-- src/content/config.ts | 40 ++--- src/global.d.ts | 10 +- src/i18n/i18nKey.ts | 52 +++---- src/i18n/languages/en.ts | 56 +++---- src/i18n/languages/es.ts | 56 +++---- src/i18n/languages/ja.ts | 56 +++---- src/i18n/languages/ko.ts | 56 +++---- src/i18n/languages/th.ts | 56 +++---- src/i18n/languages/zh_CN.ts | 56 +++---- src/i18n/languages/zh_TW.ts | 56 +++---- src/i18n/translation.ts | 58 +++---- src/layouts/Layout.astro | 82 +++++----- src/layouts/MainGridLayout.astro | 53 ++++--- src/pages/[...page].astro | 22 +-- src/pages/about.astro | 18 +-- src/pages/archive/category/[category].astro | 28 ++-- .../archive/category/uncategorized.astro | 10 +- src/pages/archive/index.astro | 8 +- src/pages/archive/tag/[tag].astro | 38 ++--- src/pages/posts/[...slug].astro | 74 ++++----- src/pages/robots.txt.ts | 18 +-- src/pages/rss.xml.ts | 54 +++---- src/plugins/rehype-component-admonition.mjs | 36 ++--- src/plugins/rehype-component-github-card.mjs | 116 +++++++------- src/plugins/remark-directive-rehype.js | 52 +++---- src/plugins/remark-excerpt.js | 24 +-- src/plugins/remark-reading-time.mjs | 22 +-- src/types/config.ts | 132 ++++++++-------- src/utils/content-utils.ts | 128 ++++++++------- src/utils/date-utils.ts | 2 +- src/utils/setting-utils.ts | 70 ++++----- src/utils/url-utils.ts | 34 ++-- 61 files changed, 1329 insertions(+), 1307 deletions(-) diff --git a/biome.json b/biome.json index 0c7acf3c..4ccad49c 100644 --- a/biome.json +++ b/biome.json @@ -7,7 +7,7 @@ }, "files": { "ignoreUnknown": false, - "ignore": [] + "ignore": ["src/**/*.css","src/public/**/*", "dist/**/*", "node_modules/**/*"] }, "formatter": { "enabled": true, diff --git a/src/components/ArchivePanel.astro b/src/components/ArchivePanel.astro index 102a53a3..24159c8c 100644 --- a/src/components/ArchivePanel.astro +++ b/src/components/ArchivePanel.astro @@ -1,67 +1,67 @@ --- -import { UNCATEGORIZED } from '@constants/constants' -import I18nKey from '../i18n/i18nKey' -import { i18n } from '../i18n/translation' -import { getSortedPosts } from '../utils/content-utils' -import { getPostUrlBySlug } from '../utils/url-utils' +import { UNCATEGORIZED } from "@constants/constants"; +import I18nKey from "../i18n/i18nKey"; +import { i18n } from "../i18n/translation"; +import { getSortedPosts } from "../utils/content-utils"; +import { getPostUrlBySlug } from "../utils/url-utils"; interface Props { - keyword?: string - tags?: string[] - categories?: string[] + keyword?: string; + tags?: string[]; + categories?: string[]; } -const { tags, categories } = Astro.props +const { tags, categories } = Astro.props; -let posts = await getSortedPosts() +let posts = await getSortedPosts(); if (Array.isArray(tags) && tags.length > 0) { - posts = posts.filter( - post => - Array.isArray(post.data.tags) && - post.data.tags.some(tag => tags.includes(tag)), - ) + posts = posts.filter( + (post) => + Array.isArray(post.data.tags) && + post.data.tags.some((tag) => tags.includes(tag)), + ); } if (Array.isArray(categories) && categories.length > 0) { - posts = posts.filter( - post => - (post.data.category && categories.includes(post.data.category)) || - (!post.data.category && categories.includes(UNCATEGORIZED)), - ) + posts = posts.filter( + (post) => + (post.data.category && categories.includes(post.data.category)) || + (!post.data.category && categories.includes(UNCATEGORIZED)), + ); } const groups: { year: number; posts: typeof posts }[] = (() => { - const groupedPosts = posts.reduce( - (grouped: { [year: number]: typeof posts }, post) => { - const year = post.data.published.getFullYear() - if (!grouped[year]) { - grouped[year] = [] - } - grouped[year].push(post) - return grouped - }, - {}, - ) + const groupedPosts = posts.reduce( + (grouped: { [year: number]: typeof posts }, post) => { + const year = post.data.published.getFullYear(); + if (!grouped[year]) { + grouped[year] = []; + } + grouped[year].push(post); + return grouped; + }, + {}, + ); - // convert the object to an array - const groupedPostsArray = Object.keys(groupedPosts).map(key => ({ - year: Number.parseInt(key), - posts: groupedPosts[Number.parseInt(key)], - })) + // convert the object to an array + const groupedPostsArray = Object.keys(groupedPosts).map((key) => ({ + year: Number.parseInt(key), + posts: groupedPosts[Number.parseInt(key)], + })); - // sort years by latest first - groupedPostsArray.sort((a, b) => b.year - a.year) - return groupedPostsArray -})() + // sort years by latest first + groupedPostsArray.sort((a, b) => b.year - a.year); + return groupedPostsArray; +})(); function formatDate(date: Date) { - const month = (date.getMonth() + 1).toString().padStart(2, '0') - const day = date.getDate().toString().padStart(2, '0') - return `${month}-${day}` + const month = (date.getMonth() + 1).toString().padStart(2, "0"); + const day = date.getDate().toString().padStart(2, "0"); + return `${month}-${day}`; } function formatTag(tag: string[]) { - return tag.map(t => `#${t}`).join(' ') + return tag.map((t) => `#${t}`).join(" "); } --- diff --git a/src/components/ConfigCarrier.astro b/src/components/ConfigCarrier.astro index 3cecd5b0..68b3dde4 100644 --- a/src/components/ConfigCarrier.astro +++ b/src/components/ConfigCarrier.astro @@ -1,6 +1,6 @@ --- -import { siteConfig } from '../config' +import { siteConfig } from "../config"; ---
diff --git a/src/components/Footer.astro b/src/components/Footer.astro index dd07747a..d679a086 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,8 +1,8 @@ --- -import { profileConfig } from '../config' -import { url } from '../utils/url-utils' -const currentYear = new Date().getFullYear() +import { profileConfig } from "../config"; +import { url } from "../utils/url-utils"; +const currentYear = new Date().getFullYear(); --- diff --git a/src/components/LightDarkSwitch.svelte b/src/components/LightDarkSwitch.svelte index 8c997ec1..62ae7da6 100644 --- a/src/components/LightDarkSwitch.svelte +++ b/src/components/LightDarkSwitch.svelte @@ -1,59 +1,59 @@ diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index eb6a8d3f..bbc31cbf 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -1,23 +1,23 @@ --- -import { Icon } from 'astro-icon/components' -import DisplaySettings from './widget/DisplaySettings.svelte' -import { LinkPreset, type NavBarLink } from '../types/config' -import { navBarConfig, siteConfig } from '../config' -import NavMenuPanel from './widget/NavMenuPanel.astro' -import Search from './Search.svelte' -import { LinkPresets } from '../constants/link-presets' -import LightDarkSwitch from './LightDarkSwitch.svelte' -import { url } from '../utils/url-utils' -const className = Astro.props.class +import { Icon } from "astro-icon/components"; +import { navBarConfig, siteConfig } from "../config"; +import { LinkPresets } from "../constants/link-presets"; +import { LinkPreset, type NavBarLink } from "../types/config"; +import { url } from "../utils/url-utils"; +import LightDarkSwitch from "./LightDarkSwitch.svelte"; +import Search from "./Search.svelte"; +import DisplaySettings from "./widget/DisplaySettings.svelte"; +import NavMenuPanel from "./widget/NavMenuPanel.astro"; +const className = Astro.props.class; let links: NavBarLink[] = navBarConfig.links.map( - (item: NavBarLink | LinkPreset): NavBarLink => { - if (typeof item === 'number') { - return LinkPresets[item] - } - return item - }, -) + (item: NavBarLink | LinkPreset): NavBarLink => { + if (typeof item === "number") { + return LinkPresets[item]; + } + return item; + }, +); ---