Skip to content

RazDechantal/vite-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Here is a README file to the project, including a relevant table of contents:

Sure! Below is the updated README file that reflects the current structure and features of your Vite Blog Application.


Vite Blog Application

This is a simple blog application built with React and Vite, featuring Firebase authentication for user management. Users can read posts, write their own posts, add comments, and manage their posts.

Table of Contents

Getting Started

Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.

Project Structure

src/
|-- components/
| |-- BlogPost.jsx
| |-- BlogPostList.jsx
| |-- Comment.jsx
| |-- CommentList.jsx
| |-- Navbar.jsx
| |-- PrivateRoute.jsx
| |-- ErrorBoundary.jsx
|-- context/
| |-- AuthContext.jsx
| |-- BlogContext.jsx
|-- pages/
| |-- HomePage.jsx
| |-- MyPostsPage.jsx
| |-- LoginPage.jsx
| |-- SignupPage.jsx
| |-- AddPostPage.jsx
|-- App.jsx
|-- App.css
|-- index.jsx
|-- firebase.js
|-- vite.config.js
  • components/: Contains reusable React components.
  • context/: Contains context providers for managing global state.
  • pages/: Contains the main pages of the application.
  • App.jsx: The root component that sets up routing and context providers.
  • App.css: The main CSS file for styling the application.
  • index.jsx: The entry point of the application.
  • firebase.js: Configuration file for Firebase.

Features

  1. Multi-page Application with Navigation: Navigate between different pages of the app.
  2. User Authentication: Real login via Firebase, replacing UserContext.
  3. Blog Posts: Read posts, write new posts, edit, and delete your own posts.
  4. Comments: Add and view comments on blog posts.
  5. Protected Routes: Routes that should only be visible to logged-in users are protected.
  6. Deployment: The application can be deployed using Netlify.
  7. User Alias: Display user alias instead of full email in the Navbar.

Setup and Installation

Prerequisites

  • Node.js (v16 or later recommended)
  • npm or yarn

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd vite-project
    
  2. Install dependencies:

    npm install
  3. Set up Firebase:

    • Create a Firebase project at Firebase Console.
    • Enable Email/Password authentication.
    • Enable Firestore Database.
    • Copy the Firebase configuration and set up environment variables as described below.

Environment Variables

Create a .env file in the root of your project and add your Firebase configuration:

VITE_API_KEY=your_api_key
VITE_AUTH_DOMAIN=your_project_id.firebaseapp.com
VITE_PROJECT_ID=your_project_id
VITE_STORAGE_BUCKET=your_project_id.appspot.com
VITE_MESSAGING_SENDER_ID=your_messaging_sender_id
VITE_APP_ID=your_app_id

Firestore Security Rules

Ensure that your Firestore security rules allow authenticated users to read and write to the posts collection. Here is an example:

service cloud.firestore {
  match /databases/{database}/documents {
    match /posts/{post} {
      allow read: if true;
      allow write: if request.auth != null;
    }
  }
}

To set up these rules:

  1. Go to the Firebase Console.
  2. Select your project.
  3. Navigate to Firestore Database in the left-hand menu.
  4. Click on the "Rules" tab at the top of the Firestore page.
  5. Update the rules with the provided example and publish the changes.

Available Scripts

In the project directory, you can run:

npm run dev

Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.

npm run build

Builds the app for production to the dist folder. It correctly bundles React in production mode and optimizes the build for the best performance.

npm run serve

Serves the production build from the dist folder.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.


This README file should provide a clear overview of your project and instructions on how to set it up and run it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published