Staticman 評論模塊

Staticman 評論模塊

Staticman 評論模塊爲其他模塊提供了一個靈活的模板,以生成評論表單和顯示嵌套的評論。

Modulegithub.com/hbstack/staticman-comments
Repository⭐ Please consider giving a star if your like it.
Stars
Version
Used by
Requirements
License
UsageSee how to use modules.

特性§

  • 嵌套評論。
  • 完全靜態化,評論存儲於 Git 倉庫中,並靜態地渲染。
  • reCaptcha.

要求§

  • Staticman 實例。

模板§

1{{ partial "hb/modules/staticman-comments/index" site.Params.my_staticman }}
go-html-template

然後聲明默認的參數。

hugo.toml

1[params]
2  [params.my_staticman]
3    branch = 'main'
4    endpoint = 'https://staticman.hugomods.com/'
5    moderation = true
6    property = 'comments'
7    repo = 'user/repo'
8    required_fields = ['email', 'url']
9    service = 'github'
toml

hugo.yaml

 1params:
 2  my_staticman:
 3    branch: main
 4    endpoint: https://staticman.hugomods.com/
 5    moderation: true
 6    property: comments
 7    repo: user/repo
 8    required_fields:
 9    - email
10    - url
11    service: github
yaml

hugo.json

 1{
 2   "params": {
 3      "my_staticman": {
 4         "branch": "main",
 5         "endpoint": "https://staticman.hugomods.com/",
 6         "moderation": true,
 7         "property": "comments",
 8         "repo": "user/repo",
 9         "required_fields": [
10            "email",
11            "url"
12         ],
13         "service": "github"
14      }
15   }
16}
json

模板參數§

ParameterTypeRequiredDescription
endpointstringYStaticman 實例的 endpoint,如:https://staticman.hugomods.com/
servicestringYGit 服務提供商: github, gitlabonedev
repostringYGit 倉庫名稱, i.e. user/repo.
branchstringY分支名稱,如:mainmaster
propertystringYStaticman 的屬性,如:comments
moderationbooleanY是否開啓 moderation,需與 Staticman 配置相一致。
required_fieldsarray額外的必填項,有效選項:emailurl
reCaptchaobjectreCaptcha v2.
reCaptcha.sitekeystringreCaptcha v2 site key.
reCaptcha.secretstringreCaptcha v2 encrypted1 secret.

Staticman 配置§

此外,你還需要於倉庫根目錄創建 staticman.yml,舉個例子。

staticman.yml
 1# Name of the property. You can have multiple properties with completely
 2# different config blocks for different sections of your site.
 3# For example, you can have one property to handle comment submission and
 4# another one to handle posts.
 5comments:
 6  # (*) REQUIRED
 7  #
 8  # Names of the fields the form is allowed to submit. If a field that is
 9  # not here is part of the request, an error will be thrown.
10  allowedFields: ["name", "email", "url", "message", "reply_to", "root_id"]
11
12  # (*) REQUIRED
13  #
14  # Name of the branch being used. Must match the one sent in the URL of the
15  # request.
16  branch: "main"
17
18  # Text to use as the commit message or pull request title. Accepts placeholders.
19  commitMessage: "chore: add Staticman comment"
20
21  # (*) REQUIRED
22  #
23  # Destination path (filename) for the data files. Accepts placeholders.
24  filename: "{@id}"
25
26  # The format of the generated data files. Accepted values are "json", "yaml"
27  # or "frontmatter"
28  format: "yaml"
29
30  # List of fields to be populated automatically by Staticman and included in
31  # the data file. Keys are the name of the field. The value can be an object
32  # with a `type` property, which configures the generated field, or any value
33  # to be used directly (e.g. a string, number or array)
34  generatedFields:
35    date:
36      type: date
37      options:
38        format: "timestamp-seconds"
39
40  # Whether entries need to be appproved before they are published to the main
41  # branch. If set to `true`, a pull request will be created for your approval.
42  # Otherwise, entries will be published to the main branch automatically.
43  moderation: true
44
45  # Name of the site. Used in notification emails.
46  # name: "hbstack.dev"
47
48  # Notification settings. When enabled, users can choose to receive notifications
49  # via email when someone adds a reply or a new comment. This requires an account
50  # with Mailgun, which you can get for free at http://mailgun.com.
51  #notifications:
52    # Enable notifications
53    #enabled: true
54
55    # (!) ENCRYPTED
56    #
57    # Mailgun API key
58    #apiKey: "1q2w3e4r"
59
60    # (!) ENCRYPTED
61    #
62    # Mailgun domain (encrypted)
63    #domain: "4r3e2w1q"
64
65  # (*) REQUIRED
66  #
67  # Destination path (directory) for the data files. Accepts placeholders.
68  path: "data/comments/{options.slug}"
69
70  # Names of required fields. If any of these isn't in the request or is empty,
71  # an error will be thrown.
72  requiredFields: ["name", "message"]
73
74  # List of transformations to apply to any of the fields supplied. Keys are
75  # the name of the field and values are possible transformation types.
76  transforms:
77    email: md5
78
79  reCaptcha:
80    enabled: true
81    siteKey: 6LcWQH0gAAAAAJPZN9S-wrugRUukNOiHfxmFOSM5
82    secret: "Tba8b3unYkkAY2zaITA3Or1Jg0vjaW+2ZOfxBCb/IdivpOMLacJabaVhHeOYnSOwhNF668U3giPW0Z1qYuj6HiFoml/TIZcuevk7A+8vCUVAbVXMJBKAVM7ONIZ3EsURtAvU4BDUTVe/Cb3qvwlAZeCO6RE+xWJh2ixvaLG8WyACvs+7ank+UP+pmS93c+haXMcsatIX4XUl/uYBPWqVVobhDcjG2Sfaar0F+eqVp5bRbZKzJaPvrnWD7aVlBJ+bi/HL7U4fR+sDWmtMEe0KbEOihDs0rh13+KAhfWK83E1mbJeB3jumlqcTui2V+IyXDe5I8eQwt8o79tKr4VbmvQ=="
yaml

  1. 你需要打開 https://ennpoint/v3/encrypt/SECRET 以加密敏感數據,比如:https://staticman.hugomods.com/v3/encrypt/MY_SECRET。 ↩︎

  • 全部
  • English
  • 简体中文
  • 繁體中文
  • 最佳匹配
  • 最舊的
  • 最新的
  • 2020
  • 2022
  • 2023
  • HB Framework Authors
  • Hugo Authors
  • Banner
  • Build Tools
  • Comments
  • Configuration
  • Deployment
  • Develop
  • Footer
  • Header
  • Inline Frame
  • Installation
  • Look and Feel
  • Menus
  • Module
  • Modules
  • Shortcode
  • Sidebar
  • 侧边栏
  • 内容
  • 安装
  • 开发
  • 构建工具
  • 概览
  • 模块
  • 横幅
  • 短代码
  • 菜单
  • 观感
  • 评论
  • 部署
  • 配置
  • 页头
  • 页尾
  • 側邊欄
  • 內容
  • 安裝
  • 概覽
  • 構建工具
  • 模塊
  • 橫幅
  • 短代碼
  • 菜單
  • 觀感
  • 評論
  • 開發
  • 頁尾
  • 頁頭
  • Docs
  • Examples
  • Modules
  • News
  • Showcases
  • Themes
  • Tutorials
  • 教程
  • 文档
  • 新闻
  • 模块
  • 示例
  • 文檔
  • 新聞
  • 模塊
  • Alert
  • Animations
  • AOS
  • Applications
  • asciinema
  • Authors
  • Autoprefixer
  • Back to top
  • Background Image
  • beian
  • Bigger Picture
  • Bilibili
  • Blog
  • Bootstrap
  • Breadcrumb
  • Breakpoint
  • Classic
  • clean
  • Clearfix
  • Cloudflare Pages
  • Code Block Panel
  • CodePen
  • Comments
  • Comments Engine
  • Config Toggle
  • Contact
  • Contact Form
  • Content Panel
  • CSS
  • Dark Mode
  • defaultContentLanguageInSubdir
  • Diagrams
  • Disqus
  • Docker
  • Docs
  • DocSearch
  • Domain
  • Featured Image
  • Figure
  • Fonts
  • Footer
  • Footer Menus
  • frame
  • Gallery
  • GCSE
  • Giscus
  • Gist
  • Git
  • GitHub Pages
  • Go
  • Google
  • Google Fonts
  • graph
  • Header
  • Header Menus
  • Heading Sign
  • Highlight
  • HLS
  • Hooks
  • HTML
  • Hugo
  • Icon
  • iframe
  • Image
  • Image Link
  • Instagram
  • Introduction
  • JavaScript
  • JS
  • JSRun
  • KaTex
  • Language Picker
  • Lead
  • Light Mode
  • Markdown
  • Menus
  • Mermaid
  • Meta
  • Module
  • MPD
  • MPEG-DASH
  • Multilingual
  • NetEase Could Music
  • Netlify
  • News
  • Node.js
  • noscript
  • NPM
  • Pagination
  • Param
  • Picture
  • Pills
  • PostCSS
  • Posts
  • Profile
  • Progress Bar
  • PurgeCSS
  • PWA
  • Ratio
  • ref
  • Related Posts
  • relref
  • Return to top
  • RTLCSS
  • Scrollbar
  • Scrollspy
  • SCSS
  • Search
  • Search Engines
  • Slide
  • Social Links
  • Socials
  • Start Page
  • Staticman
  • Style Guide
  • Syntax Highlighting
  • Table of Contents
  • Taxonomies
  • Theme
  • Themes
  • tidy
  • ToC
  • Toggle
  • Tweet
  • Twikoo
  • TypeScript
  • Utterances
  • Videos
  • Vimeo
  • YouKu
  • YouTube
  • Front Matter
  • JSON
  • TOML
  • YAML
  • 主题
  • 代码块面板
  • 优酷
  • 作者
  • 元模块
  • 公告栏
  • 内容面板
  • 内容面板模块
  • 分类
  • 分页
  • 动画
  • 博客
  • 哔哩哔哩
  • 回到顶部
  • 图库
  • 图标
  • 图片
  • 图片链接
  • 图表
  • 域名
  • 备案
  • 多语言
  • 字体
  • 幻灯片
  • 搜索
  • 文档
  • 文章
  • 断点
  • 新闻
  • 标题链接
  • 浅色模式
  • 深色模式
  • 滚动条
  • 特色图片
  • 目录
  • 相关文章
  • 社交链接
  • 简介
  • 网易云音乐
  • 联系表单
  • 背景图片
  • 菜单
  • 视频
  • 评论
  • 评论引擎
  • 语法高亮
  • 语言选项
  • 谷歌
  • 谷歌字体
  • 返回顶部
  • 进度条
  • 钩子
  • 面包屑导航
  • 页头
  • 页头菜单
  • 页尾
  • 页尾菜单
  • 风格指南
  • 主題
  • 代碼塊面板
  • 備案
  • 優酷
  • 元模塊
  • 內容面板
  • 內容面板模塊
  • 公告欄
  • 分頁
  • 分類
  • 動畫
  • 嗶哩嗶哩
  • 回到頂部
  • 圖庫
  • 圖標
  • 圖片
  • 圖片鏈接
  • 圖表
  • 多語言
  • 字體
  • 幻燈片
  • 文檔
  • 新聞
  • 斷點
  • 標題鏈接
  • 淺色模式
  • 滾動條
  • 特色圖片
  • 目錄
  • 相關文章
  • 社交鏈接
  • 簡介
  • 網易雲音樂
  • 聯繫表單
  • 背景圖片
  • 菜單
  • 視頻
  • 評論
  • 評論引擎
  • 語法高亮
  • 語言選項
  • 谷歌字體
  • 返回頂部
  • 進度條
  • 鉤子
  • 頁尾
  • 頁尾菜單
  • 頁頭
  • 頁頭菜單
  • 風格指南
  • 麪包屑導航