[update] migrate the project formatter from prettier and eslint to biome
This commit is contained in:
@@ -8,6 +8,7 @@ export function checkAndCreateDirectory(dirPath: string) {
|
||||
fs.accessSync(dirPath, fs.constants.R_OK | fs.constants.W_OK);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +21,7 @@ export function isDirectoryEmptySync(directory: string) {
|
||||
const files = fs.readdirSync(directory);
|
||||
return files.length === 0;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { PostFilesDirectory } from "@/consts/consts";
|
||||
import { TFrontmatter } from "@/types/frontmatter.type";
|
||||
import { TPostListItem, TPostsByTag } from "@/types/post-list";
|
||||
import fs from "fs";
|
||||
import { serialize } from "next-mdx-remote/serialize";
|
||||
import path from "path";
|
||||
import { PostFilesDirectory } from "@/consts/consts";
|
||||
import type { TFrontmatter } from "@/types/frontmatter.type";
|
||||
import type { TPostListItem, TPostsByTag } from "@/types/post-list";
|
||||
import { serialize } from "next-mdx-remote/serialize";
|
||||
import { titleCase } from "title-case";
|
||||
import { isEmptyString, nullifyEmptyArray, nullifyEmptyString } from "./utils";
|
||||
|
||||
@@ -38,7 +38,7 @@ async function extractFrontmatters(filepath: string): Promise<TFrontmatter> {
|
||||
function readPostsDirectory(): string[] {
|
||||
const result: string[] = [];
|
||||
const files = fs.readdirSync(PostFilesDirectory);
|
||||
|
||||
|
||||
for (const fileName of files) {
|
||||
const filePath = path.join(PostFilesDirectory, fileName);
|
||||
const fileStat = fs.statSync(filePath);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from "fs";
|
||||
import { CopyrightAnnouncement, LatestPostCountInHomePage, WebsiteURL } from "@/consts/consts";
|
||||
import { Config } from "@/data/config";
|
||||
import { Feed } from "feed";
|
||||
import fs from "fs";
|
||||
import { JSDOM } from "jsdom";
|
||||
import { MDXRemote } from "next-mdx-remote";
|
||||
import { serialize } from "next-mdx-remote/serialize";
|
||||
@@ -17,7 +17,8 @@ import remarkMath from "remark-math";
|
||||
import remarkPrism from "remark-prism";
|
||||
import { getPostFileContent, sortedPosts } from "./post-process";
|
||||
|
||||
const NoticeForRSSReaders = `\n---\n**NOTE:** Different RSS reader may have deficient even no support for svg formulations rendering. If it happens, please read the origin page to have better experience.`;
|
||||
const NoticeForRSSReaders =
|
||||
"\n---\n**NOTE:** Different RSS reader may have deficient even no support for svg formulations rendering. If it happens, please read the origin page to have better experience.";
|
||||
|
||||
function minifyHTMLCode(htmlString: string): string {
|
||||
const dom = new JSDOM(htmlString);
|
||||
@@ -61,7 +62,7 @@ export const generateRSSFeed = async () => {
|
||||
for (let i = 0; i < Math.min(LatestPostCountInHomePage, sortedPosts.allPostList.length); i++) {
|
||||
const post = sortedPosts.allPostList[i];
|
||||
const postFileContent = `${getPostFileContent(post.id)}${NoticeForRSSReaders}}`;
|
||||
const dateNumber = post.frontMatter.time.split("-").map((num) => parseInt(num));
|
||||
const dateNumber = post.frontMatter.time.split("-").map((num) => Number.parseInt(num));
|
||||
const mdxSource = await serialize(postFileContent ?? "", {
|
||||
parseFrontmatter: true,
|
||||
mdxOptions: {
|
||||
|
||||
@@ -23,7 +23,7 @@ function tokenizer(str: string) {
|
||||
|
||||
function makeSearchIndex() {
|
||||
const startTime = Date.now();
|
||||
let miniSearch = new minisearch({
|
||||
const miniSearch = new minisearch({
|
||||
fields: ["id", "title", "tags", "subtitle", "summary", "content"],
|
||||
storeFields: ["id", "title", "tags", "summary"],
|
||||
tokenize: tokenizer,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TTOCItem } from "@/types/toc.type";
|
||||
import type { TTOCItem } from "@/types/toc.type";
|
||||
import { JSDOM } from "jsdom";
|
||||
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ export const makeTOCTree = (htmlCode: string) => {
|
||||
const all_headers = doc_dom.window.document.querySelectorAll("h1,h2,h3,h4,h5,h6");
|
||||
const result: TTOCItem[] = [];
|
||||
for (let i = 0; i < all_headers.length; i++) {
|
||||
const level = parseInt(all_headers[i].tagName.replace("H", ""));
|
||||
const level = Number.parseInt(all_headers[i].tagName.replace("H", ""));
|
||||
result.push({
|
||||
level: level,
|
||||
anchorId: all_headers[i].id,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NonEmptyArray } from "@/types/utils.type";
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import type { NonEmptyArray } from "@/types/utils.type";
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
|
||||
Reference in New Issue
Block a user