Wednesday 11 May 2022

NetlifyCMS

static な web page 生成は hugo でやるわけですが、Netlify CMSは、

  gitlab での *.md の生成を web 上で会話的にやることで blog的なものを作る

わけですね。Head less とかいうんだが、gitlab 使うから、DBがないわけ。

  gitlab は DB としてくそだろ

という意見には賛成するしかないわけですが。なんが、設定が全然できず。

  要するに、private gitlab とか想定されてなくって、github とかそんなのばっかり

でも、だいたいわかった。どうも、NetlifyCMS のサイト自体は、どうでも良い感じ。

自分のサイトで回す分には Oauth もいらないのかも。

 Hugo を動くようにする
 Hugoを gitlab に結び付ける

つまり、git init / git clone すればよい。そこに

 admin という directory を掘って
 以下の config.yml と index.html を置く
 gitlab の admin から application を選択
 新しくapplication を作る
 scope は api にする
 gitlab で必要な permission を許可する

Application id を config.yml に。

 redirect URIを admin の index.html

に向ける。で動くようです。

なるほど。このあたり、生成系を容易、あるいは、gitのtemplateをつくるとよいかもな。

誰かが設定した時の記録がまったくなくて... 結構、てさぐりだった。前に自分でやったような記憶もあるが、

  気のせい

だったみたいです。

admin/config.yml
  backend:
   name: gitlab
   repo: ie-web/programming3
   auth_type: pkce
   app_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   api_root: https://gitlab.xx.u-ryukyu.ac.jp/api/v4
   base_url: https://gitlab.xx.u-ryukyu.ac.jp
   auth_endpoint: oauth/authorize
   site_domain: https://xx.u-ryukyu.ac.jp

admin/index.html
  <!doctype html>
  <html>
  <head>
   <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <title>Content Manager</title>
  </head>
  <body>
   <!-- Include the script that builds the page and powers Netlify CMS -->
   <script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
  </body>
  </html>

No comments: