Skip to content

Commit

Permalink
Merge pull request #64 from disqus/update-readme
Browse files Browse the repository at this point in the history
Update package documentation
  • Loading branch information
tterb authored Mar 26, 2020
2 parents eebf8bf + 495ca20 commit fc13d20
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 64 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/question_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name: Question
about: Ask a question about the package
---

<!-- Make sure to check the [FAQ](https://github.com/disqus/disqus-react/wiki/Frequently-Asked-Questions) and the [Disqus Knowledge base](https://help.disqus.com/) before submitting a new question. -->

118 changes: 70 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,87 @@
# disqus-react
# disqus-react

disqus-react is a component for integrating the Disqus comments embed and comment count into a React.js single-page application. All components support live reloads when new prop data is received.
[![npm version](https://badge.fury.io/js/disqus-react.svg)](https://badge.fury.io/js/disqus-react "View this package on npm")

Installation
============
A package for integrating [Disqus](http://disqus.com/) services into React applications.

Using NPM:
## Installation

Using [npm](https://www.npmjs.com/):

```bash
$ npm install --save disqus-react
```

Using [yarn](https://yarnpkg.com/):
```bash
$ npm install disqus-react
$ yarn add disqus-react
```

## Usage

### DiscussionEmbed

This is the component that will load the main Disqus comments section.

```js
import { DiscussionEmbed } from 'disqus-react';

<DiscussionEmbed
shortname='example'
config={
url: this.props.article.url,
identifier: this.props.article.id,
title: this.props.article.title,
}
/>
```

Basic Usage
===========
This component is limited to one instance in the DOM at a time and will handle updates to both the `config` and `shortname` props and reload appropriately with the new discussion thread.


### CommentCount

On a typical article page with the comment count below the title, as well as an embedded comment and discussion below the article body.
This component will display the comment count for the Disqus thread associated with the provided config.

```js
import React from 'react';
import Disqus from 'disqus-react';
// Alternatively, import specific members:
// import { DiscussionEmbed, CommentCount, CommentEmbed } from 'disqus-react';

class Article extends React.Component {
render() {
const disqusShortname = 'example';
const disqusConfig = {
url: this.props.article.url,
identifier: this.props.article.id,
title: this.props.article.title,
};

return (
<div className="article">
<h1>{this.props.article.title}</h1>
<Disqus.CommentCount shortname={disqusShortname} config={disqusConfig}>
Comments
</Disqus.CommentCount>

<p>{this.props.article.body}</p>

<Disqus.CommentEmbed
commentId={this.props.article.featuredComment}
showMedia={true}
height={160}
/>

<Disqus.DiscussionEmbed shortname={disqusShortname} config={disqusConfig} />
</div>
);
import { CommentCount } from 'disqus-react';

<Disqus.CommentCount
shortname='example'
config={
url: this.props.article.url,
identifier: this.props.article.id,
title: this.props.article.title,
}
}
>
{/* Placeholder Text */}
Comments
</Disqus.CommentCount>
```

The `<DiscussionEmbed />` component is limited to one instance in the entire DOM at a time. If multiple are included, only one will be loaded. The component will handle updates to both the `config` and `shortname` props and reload appropriately with the new discussion thread.
Multiple instances of this component can be included on the same page with different `config` variables (e.g. an article list showing the comment count for each).
However, all threads on the site must be under the same primary site `shortname`. If the component receives a new `shortname`, all instances will be reset with counts for threads matching the updated site.


### CommentEmbed

This component can be used to embed a Disqus comment into your page.

```js
import { CommentEmbed } from 'disqus-react';

<CommentEmbed
commentId={this.props.article.featuredCommentId}
showMedia={true}
showParentComment={true}
width={420}
height={320}
/>
```

The `<CommentCount />` component may include multiple instances on the same page with different `config` variables (e.g. an article list showing the comment count for all). However, all threads on the site must be under the same primary site `shortname`. If the component receives a new `shortname`, all instances will be reset with counts for threads matching the updated site.
Multiple instances of this component may be include on the same page with different `commentId` variables and does not require that the embedded comment be under the same primary site `shortname`.

The `<CommentEmbed />` component may include multiple instances on the same page with different `commentId` variables. Additionally, this component does not require that the embedded comment be under the same primary site `shortname`.

Troubleshooting
===========
## Contributing

Make sure that `disqusProps.config.url` must match `Website URL` found at `https://your-project-shortname.disqus.com/admin/settings/general/`
If you'd like to contribute to this package feel free to submit a bug report, feature request, or pull request. Though we would ask that you first read through the [contributing guidelines](https://github.com/disqus/disqus-react/blob/master/docs/CONTRIBUTING.md).
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [1.0.8](https://github.com/disqus/disqus-react/releases/tag/1.0.7)
* Updated package documentation
* Added support for rest props to `DiscussionEmbed`
* Added config params for SSO
* Added support for additional callbacks
* Added PropType validation for components
* Updated package dependencies
* Replaced deprecated React v17.x lifecycle methods

----

## [1.0.7](https://github.com/disqus/disqus-react/releases/tag/1.0.7)
* Added shallow comparison to `shouldComponentUpdate` to fix #34
* Added "Troubleshooting" section to README.md
Expand Down
18 changes: 2 additions & 16 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Before creating bug reports, please check [this list](#before-submitting-a-bug-r
#### Before Submitting A Bug Report

* **Check the [FAQs on the forum](https://help.disqus.com/en/)** for a list of common questions and problems.
* **Check the [FAQ](https://github.com/disqus/disqus-react/wiki/Frequently-Asked-Questions)** for a list of common questions and problems.
* **Perform a [cursory search](https://github.com/disqus/disqus-react/issues?utf8=%E2%9C%93&q=is%3Aissue)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one.

#### How Do I Submit A (Good) Bug Report?
Expand Down Expand Up @@ -114,22 +114,8 @@ While the prerequisites above must be satisfied prior to having your pull reques

### JavaScript Styleguide

All JavaScript must adhere to [JavaScript Standard Style](https://standardjs.com/).
All JavaScript must adhere to the included [ESlint config](https://github.com/disqus/disqus-react/blob/master/.eslintrc.yaml)

* Prefer the object spread operator (`{...anotherObj}`) to `Object.assign()`
* Inline `export`s with expressions whenever possible
```js
// Use this:
export default class ClassName {

}

// Instead of:
class ClassName {

}
export default ClassName
```
* Place requires in the following order:
* Built-in Node Modules (such as `path`)
* Built-in Modules
Expand Down

0 comments on commit fc13d20

Please sign in to comment.