10
9

More than 3 years have passed since last update.

Emacsのorg-modeでQiita記事を書いて上げよう!!

Last updated at Posted at 2020-12-28

!macOS-11.1 !ruby-2.7.2p137

Preface (はじめに)

Qiitaの記事を作成する際にいちいちブラウザとターミナルを行ったり来たりするのは正直煩わしい…

そこで, ターミナル上でQiita記事を作成して上げれば万事解決という理念でqiita_orgというツールが作られました.

これさえあれば記事作成からアップロードまでよりスムーズに行うことができます.

install (導入)

インストールから各種設定は下の記事に詳しく書いたのでそちらを参考に進めてください.

Qiita記事作成してから上げるまで

Qiita記事作成

まず, 記事を作成するためにテンプレートを用意します.

> qiita template

すると以下のように聞かれるため, お好きな方を選んでください. 僕はすべてy にしました.

ProductName:    macOS
ProductVersion: 11.1
BuildVersion:   20C69
cp /Users/[User name]/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/qiita_org-0.1.35/lib/qiita_org/template.org template.org
Write MacOS version?(y/n) y
Write ruby version?(y/n) y

lsコマンドでカレントディレクトリの中身を表示すると確かにtemplate.orgが作成されました.

> ls .
-> template.org

では, 早速中身を見てみましょう.

> cat template.org
#+OPTIONS: ^:{}
#+STARTUP: indent nolineimages
#+TITLE: title
#+AUTHOR: [Your Name]
#+EMAIL:     (concat "your@email.com")
#+LANGUAGE:  jp
# +OPTIONS:   H:4 toc:t num:2
#+OPTIONS:   toc:nil
#+TAG: tag1, tag2
#+TWITTER: off
# +SETUPFILE: ~/.emacs.d/org-mode/theme-readtheorg.setup

![macOS-11.1](https://img.shields.io/badge/macOS-11.1-brightgreen) ![ruby-2.7.2p137](https://img.shields.io/badge/ruby-2.7.2p137-brightgreen) 

Qiitaに記事をアップロード

せっかくなので, このtemplate.orgをQiitaに上げてみましょう.

Qiitaにアップロードするためのコマンドは

> qiita post template.org

すぐに以下のような出力が出て

#<CommandLine::Result:0x00007f8443922420 @stdout="", @stderr="", @status=#<Process::Status: pid 4887 exit 0>>
["qiita", "https://qiita.com/"]
["path", "api/v2/items"]
"https://qiita.com/api/v2/items"
"Created"
       rendered_body brabrabra...
        body brabrabra...
       coediting false
      comments_count 0
      created_at 2020-12-28T20:44:04+09:00
           group 
          id 48bd0edb7d39039fd8d1
     likes_count 0
         private true
     reactions_count 0
        tags [{"name"=>"tag2", "versions"=>[]}, {"name"=>"tag1", "versions"=>[]}]
           title title
      updated_at 2020-12-28T20:44:04+09:00
         url https://qiita.com/[Your Qiita ID]/private/48bd0edb7d39039fd8d1
        user {"description"=>"", "facebook_id"=>"", "followees_count"=>1, "followers_count"=>1, "github_login_name"=>"[Your Account]", "id"=>"[Your Qiita ID]", "items_count"=>1, "linkedin_id"=>"", "location"=>"", "name"=>"[Your Name]", "organization"=>"", "permanent_id"=>266153, "profile_image_url"=>"https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266153/profile-images/1566019128", "team_only"=>false, "twitter_screen_name"=>nil, "website_url"=>""}
    page_views_count 

デフォルトのブラウザに切り替わります.参考に自分のMacでの結果を置いときます.

このとき注意として, Qiita記事の方では限定共有での公開となっていますので, 上述の方法をした後, 記事の設定から「全体に公開する」をクリックするか

アップロードする際に, 以下のようにコマンドを打つかしてください.

> qiita post template.org public

参考資料

qiita_orgのコマンドについて

10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9