diff --git a/package.json b/package.json
index c503e9f..1fd3aef 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,13 @@
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro",
- "lint": "prettier --write \"**/*.{js,jsx,ts,tsx,md,mdx,svelte,astro}\" && eslint --fix \"src/**/*.{js,ts,jsx,tsx,svelte,astro}\""
+ "lint": "prettier --write \"**/*.{js,jsx,ts,tsx,md,mdx,svelte,astro}\" && eslint --fix \"src/**/*.{js,ts,jsx,tsx,svelte,astro}\"",
+ "sort": "node scripts/updateCategoryBatchly.cjs && node scripts/sortByDate.cjs"
+ },
+ "husky": {
+ "hooks": {
+ "pre-commit": "npm run lint && npm run sort"
+ }
},
"dependencies": {
"@astrojs/check": "^0.5.6",
@@ -45,6 +51,7 @@
"eslint": "^8.57.0",
"eslint-plugin-astro": "^0.31.4",
"eslint-plugin-jsx-a11y": "^6.8.0",
+ "husky": "^9.1.6",
"prettier": "^3.2.5",
"prettier-config-standard": "^7.0.0",
"prettier-plugin-astro": "^0.13.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1e786fd..8bdbaa7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -105,6 +105,9 @@ importers:
eslint-plugin-jsx-a11y:
specifier: ^6.8.0
version: 6.8.0(eslint@8.57.0)
+ husky:
+ specifier: ^9.1.6
+ version: 9.1.6
prettier:
specifier: ^3.2.5
version: 3.2.5
@@ -2063,6 +2066,11 @@ packages:
resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==}
engines: {node: '>=16.17.0'}
+ husky@9.1.6:
+ resolution: {integrity: sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A==}
+ engines: {node: '>=18'}
+ hasBin: true
+
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@@ -6358,6 +6366,8 @@ snapshots:
human-signals@5.0.0: {}
+ husky@9.1.6: {}
+
ieee754@1.2.1: {}
ignore@5.3.1: {}
diff --git a/scripts/sortByDate.cjs b/scripts/sortByDate.cjs
index da3fb57..419c158 100644
--- a/scripts/sortByDate.cjs
+++ b/scripts/sortByDate.cjs
@@ -17,15 +17,19 @@ function processDirectory(dir) {
}
})
- // Sort files by date
+ // 按日期排序文件
fileInfos.sort((a, b) => a.date - b.date)
- // Rename files
+ // 重命名文件
fileInfos.forEach((file, index) => {
- const newName = `${index.toString().padStart(2, '0')} ${file.name}`
+ // 如果文件名已经是数字数字空格开头,则移除这个前缀
+ const oldFileName = file.name
+ const cleanFileName = oldFileName.replace(/^\d{2}\s/, '')
+
+ const newName = `${index.toString().padStart(2, '0')} ${cleanFileName}`
const newPath = path.join(dir, newName)
fs.renameSync(file.path, newPath)
- console.log(`Renamed ${file.name} to ${newName}`)
+ console.log(`重命名 ${file.name} 为 ${newName}`)
})
}
diff --git a/src/components/blog/Hero.astro b/src/components/blog/Hero.astro
index b034873..b575bfb 100644
--- a/src/components/blog/Hero.astro
+++ b/src/components/blog/Hero.astro
@@ -75,8 +75,8 @@ const dateTimeOptions: Intl.DateTimeFormatOptions = {