読書帳

記事をデフォルトでは非公開設定にする

デフォルトでは記事は非公開設定にしておきたい。その方法を調べた。

調べた所、同じ事を考えている方がいて、 rake new_post["blog_title"]で新規記事を作成した時に、ヘッダーにpublished: falseをつける方法を紹介していた([Nukino’s memorandum]より)。 この方はvimのプラグインとしてそれを実現している。

前回rake publish_draftコマンドを追加した方法にヒントを得て、自分はrake new_postコマンドに直接埋め込む事にした。

1
2
3
4
5
6
7
8
9
$ git diff Rakefile
@@ -111,6 +111,7 @@ task :new_post, :title do |t, args|
     post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %z')}"
     post.puts "comments: true"
     post.puts "categories: "
+    post.puts "published: false"
     post.puts "---"
   end
 end

今回の記事もこの方法で新規作成し、ヘッダーに「published: false」が追加された事を確認した。

vimのプラグインを用いて新規記事にデフォルトpublished: falseをつける方法。