comment-extensible
v0.1.1
Published
A React.js package for handling comments, supporting one level of replies and being database agnostic.
Downloads
4
Maintainers
Readme
Nextjs Comment Extensible
This ReactJS package provides a comments component with one level deep replies. It is designed to be database agnostic, supporting MongoDB and PostgreSQL and more...
Features
- 💬Commenting system with one level deep replies
- 📦Database agnostic: works with MongoDB, PostgreSQL and more...
- 🎉Easy to integrate into existing React projects
Table of Contents
Installation
To install the package, use npm or yarn:
npm install comment-extensible
# or
yarn add comment-extensible
Setup
MongoDB
Configure MongoDB Connection
Create a file
mongoConfig.ts
:export const mongoConfig = { mongoDBUrl: "your-mongodb-url", dbName: "your-database-name", collectionName: "comments", };
Ensure MongoDB is running and the connection URL is correctly set.
PostgreSQL
Configure PostgreSQL Connection
Create a file
postgresConfig.ts
:export const postgresConfig = { user: "your-db-user", host: "your-db-host", database: "your-database-name", password: "your-db-password", port: 5432, };
Ensure PostgreSQL is running and the connection parameters are correctly set.
Usage
Import and Use the Comment Component
Here's how you can use the Comment component in your React application for Mongo & Postgres:
// App.js
"use client";
import { CommentSection, MongoCommentRepository } from "comment-extensible";
export default function Home() {
const { mongoDBUrl, dbName, collectionName } = {
mongoDBUrl: "mongodb://localhost:27017",
dbName: "comment-extensible",
collectionName: "comment",
};
const commentRepository = new MongoCommentRepository(
mongoDBUrl,
dbName,
collectionName
);
return <CommentSection commentRepository={commentRepository} />;
}
// App.js ⚠️⚠️⚠️ Work in progress - will be out in the next version
"use client";
import { CommentSection, PostgresCommentRepository } from "comment-extensible";
export default function Home() {
const poolOptions = {
user: "postgres",
host: "localhost",
database: "comment-extensible",
password: "YOUR_PASSWORD",
port: 5432,
};
const commentRepository = new PostgresCommentRepository(poolOptions);
return <CommentSection commentRepository={commentRepository} />;
}
Contribution
We welcome contributions to enhance this package. To contribute, follow these steps:
Fork the repository on GitHub.
Clone your fork locally:
git clone https://github.com/PiusLucky/comment-extensible.git
Create a new branch for your feature or bugfix:
git checkout -b feature/your-feature-name
Make your changes and commit them:
git add . git commit -m "Add your commit message"
Push your changes to your fork:
git push origin feature/your-feature-name
Create a Pull Request on GitHub.
Code of Conduct
Please read our Code of Conduct before contributing to ensure respectful collaboration.
Running Tests
Before submitting a pull request, ensure that all tests pass:
npm test
# or
yarn test
License
This project is licensed under the MIT License. See the LICENSE file for details.