diff --git a/README.md b/README.md index 56b56ee..63f3b45 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ updated_at: "" # 記事を投稿した際に自動的に記事の更新日時に id: null # 記事を投稿した際に自動的に記事のUUIDに変わります organization_url_name: null # 関連付けるOrganizationのURL名 slide: false # true: スライドモードON / false: スライドモードOFF +ignorePublish: false # true: `publish`コマンドにおいて無視されます(Qiitaに投稿されません) / false: `publish`コマンドで処理されます(Qiitaに投稿されます) --- # new article body ``` diff --git a/src/commands/publish.ts b/src/commands/publish.ts index 2b0e9fa..a99df82 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -26,6 +26,7 @@ export const publish = async (argv: string[]) => { let targetItems: QiitaItem[]; if (args["--all"]) { targetItems = (await fileSystemRepo.loadItems()).filter((item) => { + if (item.ignorePublish === true) return false; return item.modified || item.id === null; }); } else { diff --git a/src/lib/entities/qiita-item.ts b/src/lib/entities/qiita-item.ts index dd8cb67..27e2e06 100644 --- a/src/lib/entities/qiita-item.ts +++ b/src/lib/entities/qiita-item.ts @@ -13,6 +13,7 @@ export class QiitaItem { public readonly published: boolean; public readonly itemPath: string; public readonly slide: boolean; + public readonly ignorePublish: boolean; constructor({ id, @@ -29,6 +30,7 @@ export class QiitaItem { published, itemPath, slide, + ignorePublish, }: { id: string | null; title: string; @@ -44,6 +46,7 @@ export class QiitaItem { published: boolean; itemPath: string; slide: boolean; + ignorePublish: boolean; }) { this.id = id; this.title = title; @@ -59,5 +62,6 @@ export class QiitaItem { this.published = published; this.itemPath = itemPath; this.slide = slide; + this.ignorePublish = ignorePublish; } } diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 1309e78..0a7ada4 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -14,6 +14,7 @@ class FileContent { public readonly organizationUrlName: string | null; public readonly rawBody: string; public readonly slide: boolean; + public readonly ignorePublish: boolean; constructor({ title, @@ -24,6 +25,7 @@ class FileContent { organizationUrlName, rawBody, slide, + ignorePublish = false, }: { title: string; tags: string[]; @@ -33,6 +35,7 @@ class FileContent { organizationUrlName: string | null; rawBody: string; slide: boolean; + ignorePublish: boolean; }) { this.title = title; this.tags = tags; @@ -42,6 +45,7 @@ class FileContent { this.organizationUrlName = organizationUrlName; this.rawBody = rawBody; this.slide = slide; + this.ignorePublish = ignorePublish; } static read(fileContent: string): FileContent { @@ -55,6 +59,7 @@ class FileContent { id: data.id, organizationUrlName: data.organization_url_name, slide: data.slide, + ignorePublish: data.ignorePublish ?? false, }); } @@ -74,6 +79,7 @@ class FileContent { id, organizationUrlName: null, slide: false, + ignorePublish: false, }); } @@ -87,6 +93,7 @@ class FileContent { id: item.id, organizationUrlName: item.organization_url_name, slide: item.slide, + ignorePublish: false, }); } @@ -100,6 +107,7 @@ class FileContent { id: item.id, organizationUrlName: item.organizationUrlName, slide: item.slide, + ignorePublish: item.ignorePublish, }); } @@ -112,6 +120,7 @@ class FileContent { id: this.id, organization_url_name: this.organizationUrlName, slide: this.slide, + ignorePublish: this.ignorePublish, }); } @@ -131,7 +140,8 @@ class FileContent { this.tags.sort().join() === aFileContent.tags.sort().join() && this.secret === aFileContent.secret && this.rawBody === aFileContent.rawBody && - this.slide === aFileContent.slide + this.slide === aFileContent.slide && + this.ignorePublish === aFileContent.ignorePublish ); } @@ -153,6 +163,7 @@ class FileContent { organizationUrlName: this.organizationUrlName, rawBody: this.rawBody, slide: this.slide, + ignorePublish: this.ignorePublish, }); } } @@ -364,6 +375,7 @@ export class FileSystemRepo { isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent), itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename), published: remoteFileContent !== null, + ignorePublish: localFileContent.ignorePublish, itemPath, }); } @@ -400,6 +412,7 @@ export class FileSystemRepo { isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent), itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename), published: remoteFileContent !== null, + ignorePublish: localFileContent.ignorePublish, itemPath, }); }