Issue #1824 User blog creation#2032
Open
noah-n-pham wants to merge 5 commits intoakshitagupta15june:mainfrom
Open
Issue #1824 User blog creation#2032noah-n-pham wants to merge 5 commits intoakshitagupta15june:mainfrom
noah-n-pham wants to merge 5 commits intoakshitagupta15june:mainfrom
Conversation
|
@noah-n-pham is attempting to deploy a commit to the akshitagupta15june's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue:
Closes: #1824
Description:
This PR adds the ability for users to create, view, and delete their own blog posts directly from the blog page which was mentioned in issue #1824.
Changes made:
blog.html: Added a “Create Your Blog” button below the page heading and a hidden form that appears when the user clicks the “Create Your Blog” button. The form lets users enter a blog title, author name, optional profile picture URL, optional image URL, a short description, and blog content. I also added a user-blogs-output container div for rendering user-created blog cards.
blog.js: Added renderUserBlogs() call inside the current .then() callback so user blogs load along with the default JSON blogs on page load. Added new functions at the bottom of the file: renderUserBlogs() to read from localStorage and build card HTML matching the current other blog cards style, showCreateForm() and hideCreateForm() to toggle the form visibility, submitBlog() to validate the user input and save the new blog to user’s localStorage, and deleteBlog() to remove a user’s created blog after confirmation.
blogs/user-blog.html: Created a new page for any new user created blogs that is modeled after the existing dan.html. It reads the blog ID from the URL query parameter, finds the matching blog in localStorage, and populates the page with the title, author info, date, and content.
Why localStorage implementation?
The project has a MongoDB backend in the server/ folder, but no existing blog-related API can be found. The existing blogs are only loaded from a static blog.json file. The database credentials are also not included in the repo or don't currently exist. Because of this, localStorage was used as a client-side solution instead to demonstrate the feature. However, this current implementation can be easily swapped out for a proper backend integration in the future.
Screenshots:




Checklist:
[x] My code adheres to the established style guidelines of the project.
[x] I have included comments in areas that may be difficult to understand.
[x] My changes have not introduced any new warnings.
[x] I have conducted a self-review of my code.