Qiita CLI
Qiita CLIがリリースされたようです。
Qiita CLIを使うことによって、以下のことができます。
- Qiita Preview で記事をブラウザで確認できる
- 記事のファイルの生成し、ローカルで記事を編集できる
- できるコマンドラインで投稿や更新が可能
また、
$ npx qiita init
をすることによって、GitHubで管理するプロジェクトが生成されます。
特に、投稿や更新のためGitHub Actionsが生成されるので、main
ブランチにマージするだけで投稿が可能です。これは便利です。
詳しくは、qiita-cliのリポジトリを参照してください。
GitHubで管理するためにやったこと
Qiitaの記事を管理するために、以下を行いました。
- 自分用の記事管理のリポジトリを作成
- textlintで校正を可能にする
- 記事作成用のPRを作る
作ったリポジトリは以下です。
自分用の記事管理のリポジトリを作成
GitHub上でリポジトリを作成し、npx qiita init
を叩いてpushしただけです。
簡単ですね。
textlintの導入
記事の誤字脱字等をなくし、文章の品質を高めるためにtextlintを導入しました。
textlint は、日本語の表現や句読点、typo などをルールを設定して、ルール通りではない場合は指摘してくれるツールです。
Node.js上で動きますので、npm install --save-dev textlint
で入れました。
こちらは、いくつかのpluginを入れて、ローカルで叩いて校正するようにしました。
"textlint": "^13.3.3",
"textlint-rule-first-sentence-length": "^2.0.0",
"textlint-rule-ja-hiragana-fukushi": "^1.3.0",
"textlint-rule-ja-hiragana-hojodoushi": "^1.1.0",
"textlint-rule-ja-hiragana-keishikimeishi": "^1.1.0",
"textlint-rule-ja-no-abusage": "^3.0.0",
"textlint-rule-ja-no-mixed-period": "^3.0.1",
"textlint-rule-ja-no-redundant-expression": "^4.0.1",
"textlint-rule-ja-no-weak-phrase": "^2.0.0",
"textlint-rule-ja-unnatural-alphabet": "^2.0.1",
"textlint-rule-max-kanji-continuous-len": "^1.1.1",
"textlint-rule-max-ten": "^4.0.4",
"textlint-rule-no-double-negative-ja": "^2.0.1",
"textlint-rule-no-doubled-conjunction": "^2.0.4",
"textlint-rule-no-doubled-conjunctive-particle-ga": "^2.0.5",
"textlint-rule-no-doubled-joshi": "^4.1.0",
"textlint-rule-no-dropping-the-ra": "^3.0.0",
"textlint-rule-no-hankaku-kana": "^2.0.1",
"textlint-rule-no-mix-dearu-desumasu": "^5.0.0",
"textlint-rule-no-mixed-zenkaku-and-hankaku-alphabet": "^1.0.1",
"textlint-rule-prefer-tari-tari": "^1.0.3",
"textlint-rule-sentence-length": "^4.0.2",
"textlint-rule-spellcheck-tech-word": "^5.0.0"
参考までにtextlintrcファイルを記しておきます。
{
"filters": {},
"rules": {
"first-sentence-length": true,
"ja-hiragana-fukushi": true,
"ja-hiragana-hojodoushi": true,
"ja-hiragana-keishikimeishi": true,
"ja-no-abusage": true,
"ja-no-mixed-period": true,
"ja-no-redundant-expression": true,
"ja-no-weak-phrase": true,
"ja-unnatural-alphabet": true,
"max-kanji-continuous-len": true,
"max-ten": true,
"no-double-negative-ja": true,
"no-doubled-conjunction": true,
"no-doubled-conjunctive-particle-ga": true,
"no-doubled-joshi": true,
"no-dropping-the-ra": true,
"no-hankaku-kana": true,
"no-mix-dearu-desumasu": true,
"no-mixed-zenkaku-and-hankaku-alphabet": true,
"prefer-tari-tari": true,
"sentence-length": true,
"spellcheck-tech-word": true,
}
}
今はローカルで叩くだけですが、そのうち GitHub Actionsで行うようにしたいと思っています。
記事作成用のPRを作る
あとは記事作成用にPRまで生成するようにGitHub Actionsを作成しました。
- ブランチを作成
-
qiita new
でファイルを生成 - commit & push
- PRを作成
PRを作成するときに、GitHub CLIを利用したのですが、
Actionsで行うと、
pull request create failed: GraphQL: Resource not accessible by integration (createPullRequest)
をいうエラーが出てしまいました。
こちら、secrets.GITHUB_TOKEN
だとwriteできないため、別でACCESS TOKENを生成して利用するようにしなければなりません。
ここはよくハマるのでメモしておきます。
詳しくはこちらの記事を参考してください。
今回はQiitaのコンテンツをGitHubで管理するためにやったことをメモとして書いておきました。
参考になれば幸いです。