Skip to content

Commit 7790b52

Browse files
committed
Add frontmatter check to publish command
1 parent ec6018c commit 7790b52

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/commands/publish.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import arg from "arg";
22
import process from "node:process";
3+
import { checkFrontmatterType } from "../lib/check-frontmatter-type";
34
import { config } from "../lib/config";
45
import { QiitaItem } from "../lib/entities/qiita-item";
56
import { getFileSystemRepo } from "../lib/get-file-system-repo";
@@ -44,9 +45,15 @@ export const publish = async (argv: string[]) => {
4445

4546
// Validate
4647
const invalidItemMessages = targetItems.reduce((acc, item) => {
47-
const errors = validateItem(item);
48-
if (errors.length > 0) return [...acc, { name: item.name, errors }];
49-
else return acc;
48+
const frontmatterErrors = checkFrontmatterType(item);
49+
if (frontmatterErrors.length > 0)
50+
return [...acc, { name: item.name, errors: frontmatterErrors }];
51+
52+
const validationErrors = validateItem(item);
53+
if (validationErrors.length > 0)
54+
return [...acc, { name: item.name, errors: validationErrors }];
55+
56+
return acc;
5057
}, [] as { name: string; errors: string[] }[]);
5158
if (invalidItemMessages.length > 0) {
5259
console.error("Validation error:");

src/server/api/items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
ItemsIndexViewModel,
1010
} from "../../lib/view-models/items";
1111
import { Item, QiitaApi } from "../../qiita-api";
12-
import { checkFrontmatterType } from "../lib/check-frontmatter-type";
12+
import { checkFrontmatterType } from "../../lib/check-frontmatter-type";
1313
import { getCurrentUser } from "../lib/get-current-user";
1414
import { itemUrl } from "../lib/qiita-url";
1515

0 commit comments

Comments
 (0)