Skip to content

Commit 0d49baa

Browse files
authored
Merge pull request #65 from ikepu-tp/main
Add a parameter whose name is `ignorePublish` to article markdown
2 parents 6fc357f + ff2a520 commit 0d49baa

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ updated_at: "" # 記事を投稿した際に自動的に記事の更新日時に
138138
id: null # 記事を投稿した際に自動的に記事のUUIDに変わります
139139
organization_url_name: null # 関連付けるOrganizationのURL名
140140
slide: false # true: スライドモードON / false: スライドモードOFF
141+
ignorePublish: false # true: `publish`コマンドにおいて無視されます(Qiitaに投稿されません) / false: `publish`コマンドで処理されます(Qiitaに投稿されます)
141142
---
142143
# new article body
143144
```

src/commands/publish.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const publish = async (argv: string[]) => {
2626
let targetItems: QiitaItem[];
2727
if (args["--all"]) {
2828
targetItems = (await fileSystemRepo.loadItems()).filter((item) => {
29+
if (item.ignorePublish === true) return false;
2930
return item.modified || item.id === null;
3031
});
3132
} else {

src/lib/entities/qiita-item.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class QiitaItem {
1313
public readonly published: boolean;
1414
public readonly itemPath: string;
1515
public readonly slide: boolean;
16+
public readonly ignorePublish: boolean;
1617

1718
constructor({
1819
id,
@@ -29,6 +30,7 @@ export class QiitaItem {
2930
published,
3031
itemPath,
3132
slide,
33+
ignorePublish,
3234
}: {
3335
id: string | null;
3436
title: string;
@@ -44,6 +46,7 @@ export class QiitaItem {
4446
published: boolean;
4547
itemPath: string;
4648
slide: boolean;
49+
ignorePublish: boolean;
4750
}) {
4851
this.id = id;
4952
this.title = title;
@@ -59,5 +62,6 @@ export class QiitaItem {
5962
this.published = published;
6063
this.itemPath = itemPath;
6164
this.slide = slide;
65+
this.ignorePublish = ignorePublish;
6266
}
6367
}

src/lib/file-system-repo.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class FileContent {
1414
public readonly organizationUrlName: string | null;
1515
public readonly rawBody: string;
1616
public readonly slide: boolean;
17+
public readonly ignorePublish: boolean;
1718

1819
constructor({
1920
title,
@@ -24,6 +25,7 @@ class FileContent {
2425
organizationUrlName,
2526
rawBody,
2627
slide,
28+
ignorePublish = false,
2729
}: {
2830
title: string;
2931
tags: string[];
@@ -33,6 +35,7 @@ class FileContent {
3335
organizationUrlName: string | null;
3436
rawBody: string;
3537
slide: boolean;
38+
ignorePublish: boolean;
3639
}) {
3740
this.title = title;
3841
this.tags = tags;
@@ -42,6 +45,7 @@ class FileContent {
4245
this.organizationUrlName = organizationUrlName;
4346
this.rawBody = rawBody;
4447
this.slide = slide;
48+
this.ignorePublish = ignorePublish;
4549
}
4650

4751
static read(fileContent: string): FileContent {
@@ -55,6 +59,7 @@ class FileContent {
5559
id: data.id,
5660
organizationUrlName: data.organization_url_name,
5761
slide: data.slide,
62+
ignorePublish: data.ignorePublish ?? false,
5863
});
5964
}
6065

@@ -74,6 +79,7 @@ class FileContent {
7479
id,
7580
organizationUrlName: null,
7681
slide: false,
82+
ignorePublish: false,
7783
});
7884
}
7985

@@ -87,6 +93,7 @@ class FileContent {
8793
id: item.id,
8894
organizationUrlName: item.organization_url_name,
8995
slide: item.slide,
96+
ignorePublish: false,
9097
});
9198
}
9299

@@ -100,6 +107,7 @@ class FileContent {
100107
id: item.id,
101108
organizationUrlName: item.organizationUrlName,
102109
slide: item.slide,
110+
ignorePublish: item.ignorePublish,
103111
});
104112
}
105113

@@ -112,6 +120,7 @@ class FileContent {
112120
id: this.id,
113121
organization_url_name: this.organizationUrlName,
114122
slide: this.slide,
123+
ignorePublish: this.ignorePublish,
115124
});
116125
}
117126

@@ -131,7 +140,8 @@ class FileContent {
131140
this.tags.sort().join() === aFileContent.tags.sort().join() &&
132141
this.secret === aFileContent.secret &&
133142
this.rawBody === aFileContent.rawBody &&
134-
this.slide === aFileContent.slide
143+
this.slide === aFileContent.slide &&
144+
this.ignorePublish === aFileContent.ignorePublish
135145
);
136146
}
137147

@@ -153,6 +163,7 @@ class FileContent {
153163
organizationUrlName: this.organizationUrlName,
154164
rawBody: this.rawBody,
155165
slide: this.slide,
166+
ignorePublish: this.ignorePublish,
156167
});
157168
}
158169
}
@@ -364,6 +375,7 @@ export class FileSystemRepo {
364375
isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent),
365376
itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename),
366377
published: remoteFileContent !== null,
378+
ignorePublish: localFileContent.ignorePublish,
367379
itemPath,
368380
});
369381
}
@@ -400,6 +412,7 @@ export class FileSystemRepo {
400412
isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent),
401413
itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename),
402414
published: remoteFileContent !== null,
415+
ignorePublish: localFileContent.ignorePublish,
403416
itemPath,
404417
});
405418
}

0 commit comments

Comments
 (0)