1.0.0 • Published 4 years ago

@itlangzi/comment-js v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

CommentJS

CommentJS 参考 Gitalk,主要用于博客或其他系统定制化评论

特性

在线示例

安装

  • 浏览器直接使用
<link href="https://cdn.jsdelivr.net/npm/@itlangzi/comment-js/dist/style.css" rel="stylesheet" >
<script src="https://cdn.jsdelivr.net/npm/@itlangzi/comment-js/dist/comment-js.js"></script>
  • Npm 安装
npm i --save @itlangzi/comment-js

或者

yarn add @itlangzi/comment-js
import '@itlangzi/comment-js/dist/style.css'
import CommentJS from '@itlangzi/comment-js'

使用

添加一个容器

<div id="container"></div>

初始化挂在 comment-js 插件

const commentJS = new CommentJS({
    // 发布评论的接口
    commentUrl: '',
    // 获取评论列表的接口
    commentsUrl: ''
})
commentJS.render('container')

React 中使用

import '@itlangzi/comment-js/dist/style.css'
import CommentJSComponent from '@itlangzi/comment-js/dist/react'
<CommentJSComponent options={options} />

参数【options】

  • commentUrl String
    必填 发布评论的接口

  • commentsUrl String
    必填 获取评论列表的接口

  • title String
    默认 window.document.title

  • language String
    默认 window.navigator.language || window.navigator.userLanguage

  • showCopyright Boolean
    默认 true

  • markdownGuide Boolean
    默认 true

  • commentHeader Object || Function
    默认 {}
    发布评论添加额外的请求头

  • commentParams Object || Function
    默认 {}
    发布评论添加额外的参数

  • commentBodyResolve Function
    默认 {}

  • commentsHeader Object || Function
    默认 {}
    获取评论添加额外的请求头

  • commentsParams Object || Function
    默认 {}
    获取评论添加额外的参数

  • commentsBodyResolve Function
    默认 {}

  • placeholder String
    默认 Say words
    占位文字

实例方法

  • render( String | HTMLElement )
    挂载评论插件

LICENSE

MIT License Copyright (c) 2020 Lang zi