V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xiaozy
V2EX  ›  问与答

请问 hexo 如何使用 staticman?

  •  
  •   xiaozy · 2017-12-11 01:22:03 +08:00 · 1487 次点击
    这是一个创建于 2853 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我按照官方指示做的,添加staticmanappCollaborators输入地址显示为 OK。 然后上传staticman.yml到我 hexo 所在github repositories所在根目录。 然后按照官方指示添加from

    from

    <form method="POST" action="https://api.staticman.net/v2/entry/github-username/github-repositories/comment">
      <input name="<%- url_for(post.path) %>" type="hidden" value="github repositories">
      //<%- url_for(post.path) %>是当前文章地址,我使用了 hexo-addrlink 插件所以都是‘/数字 ID/’
      //github-username 和 github-repositories 是我的相关 github 信息,因为是单机所以不写具体的了
      <!-- e.g. "2016-01-02-this-is-a-post" -->
      <input name="options[slug]" type="hidden" value="<%- url_for(post.path) %>">
      <label><input name="fields[name]" type="text">Name</label>
      <label><input name="fields[email]" type="email">E-mail</label>
      <label><textarea name="fields[message]"></textarea>Message</label>
      <button type="submit">Go!</button>
    </form>
    

    staticman.yml 配置

    comments:
      allowedFields: ["name", "email", "url", "message"]
      branch: "master"
      commitMessage: "Add Staticman data"
      filename: "entry{@timestamp}"
      format: "yaml"
      generatedFields:
        date:
          type: date
          options:
            format: "timestamp-seconds"
      moderation: true
      name: "eduardoboucas.com"
      path: "comment/{options.slug}"
      requiredFields: ["name", "email", "message"]
      transforms:
        email: md5
    

    安装 staticman 我只做到

    git clone [email protected]:eduardoboucas/staticman.git
    cd staticman
    npm install
    

    跳过了cp config.sample.json config.development.json 进行到npm start这里出错了,不知道啥原因(不知道和这个有啥关系没有)

    目前一点击 GO (提交评论)就提示

    {"success":false,"rawError":{"code":404,"status":"Not Found","message":"{\"message\":\"No commit found for the ref comment\",\"documentation_url\":\"https://developer.github.com/v3/repos/contents/\"}"},"errorCode":"GITHUB_READING_FILE"}
    

    请问怎么回事?该如何解决,希望知道解决方法的人能够给予帮助,非常感谢!~

    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2001 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:24 · PVG 13:24 · LAX 22:24 · JFK 01:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.