summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/nuldoc-src/commands/new.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vhosts/blog/nuldoc-src/commands/new.ts')
-rw-r--r--vhosts/blog/nuldoc-src/commands/new.ts97
1 files changed, 0 insertions, 97 deletions
diff --git a/vhosts/blog/nuldoc-src/commands/new.ts b/vhosts/blog/nuldoc-src/commands/new.ts
deleted file mode 100644
index 651c59e6..00000000
--- a/vhosts/blog/nuldoc-src/commands/new.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { dirname, join } from "@std/path";
-import { ensureDir } from "@std/fs";
-import { parseArgs } from "@std/cli";
-import { Config } from "../config.ts";
-
-export async function runNewCommand(config: Config) {
- const parsedArgs = parseArgs(Deno.args, {
- string: ["date"],
- });
-
- const type = parsedArgs._[1];
- if (type !== "post" && type !== "slide") {
- console.log(`Usage: nuldoc new <type>
-
-<type> must be either "post" or "slide".
-
-OPTIONS:
- --date <DATE>
-`);
- Deno.exit(1);
- }
-
- const ymd = (() => {
- if (parsedArgs.date) {
- return parsedArgs.date;
- }
-
- const now = new Date();
- const y = now.getFullYear();
- const d = (now.getMonth() + 1).toString().padStart(2, "0");
- const m = now.getDate().toString().padStart(2, "0");
- return `${y}-${d}-${m}`;
- })();
-
- const destFilePath = join(
- Deno.cwd(),
- config.locations.contentDir,
- getDirPath(type),
- ymd,
- getFilename(type),
- );
-
- await ensureDir(dirname(destFilePath));
- await Deno.writeTextFile(destFilePath, getTemplate(type, ymd));
- console.log(
- `New file ${
- destFilePath.replace(Deno.cwd(), "")
- } was successfully created.`,
- );
-}
-
-function getFilename(type: "post" | "slide"): string {
- return type === "post" ? "TODO.dj" : "TODO.toml";
-}
-
-function getDirPath(type: "post" | "slide"): string {
- return type === "post" ? "posts" : "slides";
-}
-
-function getTemplate(type: "post" | "slide", date: string): string {
- const uuid = crypto.randomUUID();
- if (type === "post") {
- return `---
-[article]
-uuid = "${uuid}"
-title = "TODO"
-description = "TODO"
-tags = [
- "TODO",
-]
-
-[[article.revisions]]
-date = "${date}"
-remark = "公開"
----
-{#TODO}
-# TODO
-
-TODO
-`;
- } else {
- return `[slide]
-uuid = "${uuid}"
-title = "TODO"
-event = "TODO"
-talkType = "TODO"
-link = "TODO"
-tags = [
- "TODO",
-]
-
-[[slide.revisions]]
-date = "${date}"
-remark = "登壇"
-`;
- }
-}