mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 23:02:53 +01:00
fix(utils): replace map with forEach to resolve biome lint error | 解决Github Action Biome 代码检查错误 (#601)
* fix(utils): replace map with forEach to resolve biome lint error * fix(utils): replace map with forEach in getCategoryList for clarity * fix(utils): specify radix parameter in Number.parseInt for clarity --------- Co-authored-by: L4Ph <me@l4ph.moe>
This commit is contained in:
@@ -75,8 +75,8 @@ onMount(async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const groupedPostsArray = Object.keys(grouped).map((yearStr) => ({
|
const groupedPostsArray = Object.keys(grouped).map((yearStr) => ({
|
||||||
year: Number.parseInt(yearStr),
|
year: Number.parseInt(yearStr, 10),
|
||||||
posts: grouped[Number.parseInt(yearStr)],
|
posts: grouped[Number.parseInt(yearStr, 10)],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
groupedPostsArray.sort((a, b) => b.year - a.year);
|
groupedPostsArray.sort((a, b) => b.year - a.year);
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ export async function getTagList(): Promise<Tag[]> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const countMap: { [key: string]: number } = {};
|
const countMap: { [key: string]: number } = {};
|
||||||
allBlogPosts.map((post: { data: { tags: string[] } }) => {
|
allBlogPosts.forEach((post: { data: { tags: string[] } }) => {
|
||||||
post.data.tags.map((tag: string) => {
|
post.data.tags.forEach((tag: string) => {
|
||||||
if (!countMap[tag]) countMap[tag] = 0;
|
if (!countMap[tag]) countMap[tag] = 0;
|
||||||
countMap[tag]++;
|
countMap[tag]++;
|
||||||
});
|
});
|
||||||
@@ -83,7 +83,7 @@ export async function getCategoryList(): Promise<Category[]> {
|
|||||||
return import.meta.env.PROD ? data.draft !== true : true;
|
return import.meta.env.PROD ? data.draft !== true : true;
|
||||||
});
|
});
|
||||||
const count: { [key: string]: number } = {};
|
const count: { [key: string]: number } = {};
|
||||||
allBlogPosts.map((post: { data: { category: string | null } }) => {
|
allBlogPosts.forEach((post: { data: { category: string | null } }) => {
|
||||||
if (!post.data.category) {
|
if (!post.data.category) {
|
||||||
const ucKey = i18n(I18nKey.uncategorized);
|
const ucKey = i18n(I18nKey.uncategorized);
|
||||||
count[ucKey] = count[ucKey] ? count[ucKey] + 1 : 1;
|
count[ucKey] = count[ucKey] ? count[ucKey] + 1 : 1;
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import type { LIGHT_DARK_MODE } from "@/types/config";
|
|||||||
export function getDefaultHue(): number {
|
export function getDefaultHue(): number {
|
||||||
const fallback = "250";
|
const fallback = "250";
|
||||||
const configCarrier = document.getElementById("config-carrier");
|
const configCarrier = document.getElementById("config-carrier");
|
||||||
return Number.parseInt(configCarrier?.dataset.hue || fallback);
|
return Number.parseInt(configCarrier?.dataset.hue || fallback, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHue(): number {
|
export function getHue(): number {
|
||||||
const stored = localStorage.getItem("hue");
|
const stored = localStorage.getItem("hue");
|
||||||
return stored ? Number.parseInt(stored) : getDefaultHue();
|
return stored ? Number.parseInt(stored, 10) : getDefaultHue();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setHue(hue: number): void {
|
export function setHue(hue: number): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user