【 Hexo網誌架設 4 】
Gitalk 評論設定

【 Hexo網誌架設 4 】Gitalk 評論設定

我的系統版本

macOS Monterey 12.4
hexo-cli: 4.3.0
Next:8.12.1

建立 GitHub OAuth APP

使用 Gitalk 必須有 GitHub OAuth,所以首先先開啟 GitHub → Setting -> Developer settings -> 點 OAuth Apps

如果沒有新增過,會像下方一樣:

然後點 Register a new application

填寫以下資料:

  • Application name - 應用程式名稱
  • Homepage URL - 應用程式網域 → 填你部落格網址
  • Application description - 應用程式描述
  • Authorization callback URL - 授權回應網址 → 填你部落格網址

然後你會得到一組 Client ID ,等一下會需要

不過還缺一個 Client secrets

點右邊按鍵來新增一個

Make sure to copy your new client secret now. You won’t be able to see it again.

這只會出現一次,要保存好。

然後到網頁最底下,按一下 update application

更新一下剛剛申請到的 Client secrets。

啟用評論區

在 NexT 底下的 _config.yml 裡,搜尋 comments,做一些更動。


# ---------------------------------------------------------------
# Comments Settings
# See: https://theme-next.js.org/docs/third-party-services/comments
# ---------------------------------------------------------------

# Multiple Comment System Support
comments:
  # Available values: tabs | buttons
  style: tabs
  # Choose a comment system to be displayed by default.
  # Available values: disqus | disqusjs | changyan | livere | gitalk | utterances
  active: gitalk
  # Setting `true` means remembering the comment system selected by the visitor.
  storage: true
  # Lazyload all comment systems.
  lazyload: false
  # Modify texts or order for any naves, here are some examples.
  nav:
    #disqus:
    #  text: Load Disqus
    #  order: -1
    gitalk:
      order: -1

開啟 Next 佈景主題的 _config.yml,然後搜尋「Gitalk」


# Gitalk
# For more information: https://gitalk.github.io
gitalk:
  enable: true
  github_id: huang0429 # GitHub 作者名稱
  repo: huang0429.github.io
  client_id: # 剛剛申請的 Client ID
  client_secret: # 剛剛申請的 Client Secret
  admin_user: huang0429 # 管理者的帳號
  distraction_free_mode: true # Facebook-like distraction free mode
  # 無干擾模式,簡單來講就是當有人留言時不去吵你。

  # When the official proxy is not available, you can change it to your own proxy address
  proxy: https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token # This is official proxy address
  # Gitalk's display language depends on user's browser or system environment
  # If you want everyone visiting your site to see a uniform language, you can set a force language value
  # Available values: en | es-ES | fr | ru | zh-CN | zh-TW
  language: zh-TW
  labels: Gitalk


以上都個好了之後,就更一下 Hexo ,然後等個幾分鐘,再做測試,去上個廁所吧!!