style: biome

优化访客统计动画逻辑
This commit is contained in:
二叉树树
2026-01-01 21:39:51 +08:00
parent 82bbc7c598
commit bb4aacb07b
164 changed files with 3945 additions and 3078 deletions

View File

@@ -1,48 +1,48 @@
/* This is a script to create a new post markdown file with front-matter */
import fs from "fs"
import path from "path"
import fs from "fs";
import path from "path";
function getDate() {
const today = new Date()
const year = today.getFullYear()
const month = String(today.getMonth() + 1).padStart(2, "0")
const day = String(today.getDate()).padStart(2, "0")
const hours = String(today.getHours()).padStart(2, "0")
const minutes = String(today.getMinutes()).padStart(2, "0")
const seconds = String(today.getSeconds()).padStart(2, "0")
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, "0");
const day = String(today.getDate()).padStart(2, "0");
const hours = String(today.getHours()).padStart(2, "0");
const minutes = String(today.getMinutes()).padStart(2, "0");
const seconds = String(today.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
}
const args = process.argv.slice(2)
const args = process.argv.slice(2);
if (args.length === 0) {
console.error(`Error: No filename argument provided
Usage: npm run new-post -- <filename>`)
process.exit(1) // Terminate the script and return error code 1
console.error(`Error: No filename argument provided
Usage: npm run new-post -- <filename>`);
process.exit(1); // Terminate the script and return error code 1
}
let fileName = args[0]
let fileName = args[0];
// Add .md extension if not present
const fileExtensionRegex = /\.(md|mdx)$/i
const fileExtensionRegex = /\.(md|mdx)$/i;
if (!fileExtensionRegex.test(fileName)) {
fileName += ".md"
fileName += ".md";
}
const targetDir = "./src/content/posts/"
const fullPath = path.join(targetDir, fileName)
const targetDir = "./src/content/posts/";
const fullPath = path.join(targetDir, fileName);
if (fs.existsSync(fullPath)) {
console.error(`Error: File ${fullPath} already exists `)
process.exit(1)
console.error(`Error: File ${fullPath} already exists `);
process.exit(1);
}
// recursive mode creates multi-level directories
const dirPath = path.dirname(fullPath)
const dirPath = path.dirname(fullPath);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true })
fs.mkdirSync(dirPath, { recursive: true });
}
const content = `---
@@ -54,8 +54,8 @@ image: ''
draft: false
lang: ''
---
`
`;
fs.writeFileSync(path.join(targetDir, fileName), content)
fs.writeFileSync(path.join(targetDir, fileName), content);
console.log(`Post ${fullPath} created`)
console.log(`Post ${fullPath} created`);