Skip to content

Commit 0d77dd4

Browse files
committed
add original blog's post from 2021
1 parent 49e5a65 commit 0d77dd4

File tree

5 files changed

+140
-43
lines changed

5 files changed

+140
-43
lines changed

scripts/new-post.js

Lines changed: 106 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@ import readline from 'readline';
66

77
const POSTS_ROOT = path.resolve('src/content/entries');
88

9+
const parseArgs = (argv) => {
10+
const args = {};
11+
for (let i = 0; i < argv.length; i += 1) {
12+
const token = argv[i];
13+
if (!token.startsWith('--')) {
14+
continue;
15+
}
16+
17+
const keyValue = token.slice(2);
18+
const [rawKey, inlineValue] = keyValue.split('=');
19+
if (inlineValue !== undefined) {
20+
args[rawKey] = inlineValue;
21+
continue;
22+
}
23+
24+
const key = rawKey;
25+
const next = argv[i + 1];
26+
if (next && !next.startsWith('--')) {
27+
args[key] = next;
28+
i += 1;
29+
} else {
30+
args[key] = true;
31+
}
32+
}
33+
return args;
34+
};
35+
36+
const cliArgs = parseArgs(process.argv.slice(2));
37+
938
const rl = readline.createInterface({
1039
input: process.stdin,
1140
output: process.stdout,
@@ -67,25 +96,95 @@ async function main() {
6796
try {
6897
console.log('🆕 Create a new entry\n');
6998

70-
const title = await question('📝 Title: ');
99+
let title = cliArgs.title || cliArgs.t || '';
100+
title = title.trim();
101+
if (!title) {
102+
title = await question('📝 Title: ');
103+
}
104+
title = title.trim();
71105
if (!title) {
72106
console.error('❌ Title is required.');
73107
process.exit(1);
74108
}
75109

76-
const languageInput = await question('🌐 Language code (ko/en, default: ko): ');
77-
const language = ['ko', 'en'].includes(languageInput.toLowerCase()) ? languageInput.toLowerCase() : 'ko';
110+
const parseLanguage = (value) => {
111+
const lowered = value.trim().toLowerCase();
112+
return ['ko', 'en'].includes(lowered) ? lowered : '';
113+
};
114+
115+
let language =
116+
typeof cliArgs.language === 'string'
117+
? parseLanguage(cliArgs.language)
118+
: typeof cliArgs.lang === 'string'
119+
? parseLanguage(cliArgs.lang)
120+
: '';
121+
122+
if (!language && typeof cliArgs.l === 'string') {
123+
language = parseLanguage(cliArgs.l);
124+
}
125+
126+
if (!language) {
127+
const languageInput = await question('🌐 Language code (ko/en, default: ko): ');
128+
language = parseLanguage(languageInput) || 'ko';
129+
}
130+
131+
if (!language) {
132+
language = 'ko';
133+
}
134+
135+
let tagsInput = '';
136+
if (typeof cliArgs.tags === 'string') {
137+
tagsInput = cliArgs.tags;
138+
} else if (Array.isArray(cliArgs.tags)) {
139+
tagsInput = cliArgs.tags.join(',');
140+
}
141+
142+
if (!tagsInput) {
143+
tagsInput = await question('🏷️ Tags (comma-separated): ');
144+
}
78145

79-
const tagsInput = await question('🏷️ Tags (comma-separated): ');
80146
const tags = tagsInput
81147
.split(',')
82148
.map((tag) => tag.trim())
83149
.filter(Boolean);
84150

85-
const draftInput = await question('📄 Save as draft? (y/N): ');
86-
const isDraft = /^y(es)?$/i.test(draftInput);
151+
const parseDraft = (input) => {
152+
if (typeof input === 'boolean') {
153+
return input;
154+
}
155+
const lowered = `${input}`.trim().toLowerCase();
156+
if (!lowered) {
157+
return false;
158+
}
159+
return ['y', 'yes', 'true', '1'].includes(lowered);
160+
};
161+
162+
let isDraft = false;
163+
if (cliArgs.draft !== undefined) {
164+
isDraft = parseDraft(cliArgs.draft);
165+
} else if (cliArgs.d !== undefined) {
166+
isDraft = parseDraft(cliArgs.d);
167+
} else {
168+
const draftInput = await question('📄 Save as draft? (y/N): ');
169+
isDraft = parseDraft(draftInput);
170+
}
171+
172+
const translationArg =
173+
cliArgs['translation-key'] ||
174+
cliArgs.translationKey ||
175+
cliArgs.key ||
176+
'';
177+
178+
let slugInput = '';
179+
if (typeof translationArg === 'string') {
180+
slugInput = translationArg;
181+
}
182+
183+
if (!slugInput) {
184+
slugInput = await question('🔖 Translation key (leave empty to use title slug): ');
185+
}
186+
slugInput = slugInput.trim();
87187

88-
const slugInput = await question('🔖 Translation key (leave empty to use title slug): ');
89188
const translationKey = slugInput ? slugify(slugInput) : slugify(title);
90189

91190
if (!translationKey) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "One More Win Before Bed"
3+
date: 2021-07-31
4+
tags: ["reflection", "work"]
5+
draft: false
6+
lang: en
7+
translationKey: "one-more-win-before-bed"
8+
9+
Let's win just one more and call it a night.
10+
11+
By the time someone said that—usually around midnight—it meant we had already dropped at least one match. Losing several rounds made it even better; those defeats became seasoning for the next victory. And that win shouldn’t be ordinary. It was best when it was a comeback, because nothing puts you to sleep quite like a comeback high.
12+
13+
The ingredients for a thrilling comeback in a game are surprisingly specific. First, the opponent needs to be about as good as we are, or maybe just a little better. Ideally both teams are in top condition. Winning because of solid play beats winning off a fluke. Then you need a bit of disadvantage. As long as the game is still recoverable, the steeper the climb, the better. Finally, my contribution has to matter. It has to be the kind of game where I stand out while still working in sync with the team.
14+
15+
Work is no different.
16+
17+
Work is most fun when we’re turning things around. The goals have to be challenging yet attainable—not impossibly hard and not insultingly easy. The sweet spot is the target that always feels just within reach. The team has to stay positive, rallying even when things get rough. Everyone needs to care about the win. And we need short-, mid-, and long-term victory conditions—milestones everyone can feel and take pride in.

src/content/entries/en/20250101-0000.en-lorem.md

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "한판만 이기고 자자."
3+
date: 2021-07-31
4+
tags: ["일상", "회고"]
5+
draft: false
6+
lang: ko
7+
translationKey: "one-more-win-before-bed"
8+
9+
한판만 이기고 자자.
10+
11+
자정 무렵이면 내가 혹은 같이 하는 친구가 꼭 하던 말이다. 이 말이 나올 때쯤이면 우리는 적어도 한 판 이상 이미 패배한 뒤다. 오히려 여러 판 졌으면 더 재밌다. 다음 승리의 조미료가 될 테니까. 그 승리는 그냥 승리가 아니라 역전승이면 더 좋다. 역전승이야말로 최고의 수면제 중 하나다.
12+
13+
게임에서 역전승이 재밌기 위한 조건들은 꽤나 상세하다. 먼저 상대와 나의 실력이 비슷하거나, 상대가 나보다 적당히 잘해야 한다. 이왕이면 나도 상대도 컨디션이 좋아야 좋다. 어이없는 실수보다는 잘해서 이기는 것이 좋다. 그다음은 약간의 불리함이다. 역전을 못 할 정도가 아니라면 불리할수록 좋다. 마지막으로 역전에서 내 역할이 커야 한다. 팀원과 조화를 이루지만 내가 돋보이는 그런 게임이 되어야 한다.
14+
15+
일에서도 마찬가지다.
16+
17+
역전일 때가 제일 재밌다. 먼저 적당히 달성이 어려운 목표가 있어야 한다. 너무 어렵거나 너무 쉬우면 안 된다. 잡힐 듯 안 잡힐 듯한 목표가 최고다. 또 팀원들이 긍정적이어야 한다. 힘든 상황에서도 으쌰으쌰 힘을 내서 해내려고 해야 한다. 다들 승리에 관심이 있어야 한다. 마지막으로는 단기, 중기, 장기적인 승리 조건이 있어야 한다. 모두가 실감할 수 있고 만족할 수 있는 승리여야만 한다.

src/content/entries/ko/20250101-0000.ko-lorem.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)