feat: add FrontMatter CMS, biome, translation, etc.

* add Frontmatter CMS

* add biome

* update

* update

* fixed & add docs

* fix translation.ts

* fix translation
This commit is contained in:
L4Ph
2024-01-21 13:54:41 +09:00
committed by GitHub
parent f9a78b3e3b
commit 197d524b53
42 changed files with 2714 additions and 12795 deletions

View File

@@ -1,41 +1,40 @@
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'); //月份从0开始所以要加1
const day = String(today.getDate()).padStart(2, '0');
const today = new Date()
const year = today.getFullYear()
const month = String(today.getMonth() + 1).padStart(2, "0") //月份从0开始所以要加1
const day = String(today.getDate()).padStart(2, "0")
return `${year}-${month}-${day}`;
return `${year}-${month}-${day}`
}
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(`ErrorFile ${fullPath} already exists `);
process.exit(1);
console.error(`ErrorFile ${fullPath} already exists `)
process.exit(1)
}
const content =
`---
const content = `---
title: ${args[0]}
published: ${getDate()}
description:
@@ -43,8 +42,8 @@ image:
tags: []
category:
---
`;
`
fs.writeFileSync(path.join(targetDir, fileName), content);
fs.writeFileSync(path.join(targetDir, fileName), content)
console.log(`Post ${fullPath} created`);
console.log(`Post ${fullPath} created`)