diff --git a/biome.json b/biome.json index f2af656..a917d34 100644 --- a/biome.json +++ b/biome.json @@ -8,7 +8,7 @@ "formatter": { "enabled": true, "formatWithErrors": false, - "ignore": [], + "ignore": ["src/config.ts"], "indentStyle": "space", "indentWidth": 2, "lineWidth": 80 diff --git a/src/components/ArchivePanel.astro b/src/components/ArchivePanel.astro index c82dbf5..b08bfdd 100644 --- a/src/components/ArchivePanel.astro +++ b/src/components/ArchivePanel.astro @@ -1,63 +1,68 @@ --- -import {getSortedPosts} from "../utils/content-utils"; -import {getPostUrlBySlug} from "../utils/url-utils"; -import {i18n} from "../i18n/translation"; -import I18nKey from "../i18n/i18nKey"; -import {UNCATEGORIZED} from "@constants/constants"; +import { getSortedPosts } from '../utils/content-utils' +import { getPostUrlBySlug } from '../utils/url-utils' +import { i18n } from '../i18n/translation' +import I18nKey from '../i18n/i18nKey' +import { UNCATEGORIZED } from '@constants/constants' interface Props { - keyword?: string; - tags?: string[]; - categories?: string[]; + keyword?: string + tags?: string[] + categories?: string[] } -const { keyword, tags, categories} = Astro.props; +const { keyword, tags, categories } = Astro.props 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}[] = function () { - 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 groups: { year: number; posts: typeof posts }[] = (function () { + 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: parseInt(key), - posts: groupedPosts[parseInt(key)] - })) + // convert the object to an array + const groupedPostsArray = Object.keys(groupedPosts).map(key => ({ + year: parseInt(key), + posts: groupedPosts[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 445be0f..3cecd5b 100644 --- a/src/components/ConfigCarrier.astro +++ b/src/components/ConfigCarrier.astro @@ -1,7 +1,6 @@ --- -import {siteConfig} from "../config"; - +import { siteConfig } from '../config' ---
diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 82814a9..14c535b 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,8 +1,7 @@ --- -import {profileConfig} from "../config"; -import {url} from "../utils/url-utils"; - +import { profileConfig } from '../config' +import { url } from '../utils/url-utils' ---
diff --git a/src/components/LightDarkSwitch.svelte b/src/components/LightDarkSwitch.svelte index 9b44385..6aacfff 100644 --- a/src/components/LightDarkSwitch.svelte +++ b/src/components/LightDarkSwitch.svelte @@ -1,10 +1,6 @@ diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index 2fb47ee..fd563cc 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -1,22 +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 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 -let links: NavBarLink[] = navBarConfig.links.map((item: NavBarLink | LinkPreset): NavBarLink => { - if (typeof item === "number") { - return LinkPresets[item] +let links: NavBarLink[] = navBarConfig.links.map( + (item: NavBarLink | LinkPreset): NavBarLink => { + if (typeof item === 'number') { + return LinkPresets[item] } - return item; -}); - + return item + }, +) ---