Pin one post to the top of your profile

Open
#125 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
express, mongodb, nodejs, react, typescript
Domain
full-stack

Research direction

Start with the User model in apps/api/src/models/User.ts and the user controller in apps/api/src/controllers/userController.ts, then read how GET /api/users/:username/posts builds its pages. Add the pinnedPost field and the PUT /api/users/me/pinned-post route, then show the pinned post first on page one only. Tests should cover refusing another user's post, clearing the pin on delete, and no duplicates. Done when the web label in PostCard.tsx and ProfilePage.tsx matches the API behaviour.

Written by the indexing model from the issue text.

Description

api enhancement help wanted web

Difficulty: Intermediate · Estimated size: 1 day

Context

The profile shows posts newest first. People often want to show their best or most important post first.

Problem or goal

Let a person pin one of their own posts. The pinned post shows first on their profile with a "Pinned" label.

Suggested approach

  • API: add pinnedPost (post id or null) to User; PUT /api/users/me/pinned-post with { postId } or null. Only the owner's own posts can be pinned.
  • Return it in the profile and make GET /api/users/:username/posts put it on the first page only, without repeating it later in the list.
  • Web: "Pin to profile" and "Unpin" in the post menu; a label on the card.

Where to look

  • apps/api/src/models/User.ts
  • apps/api/src/controllers/userController.ts
  • apps/web/src/pages/ProfilePage.tsx
  • apps/web/src/components/PostCard.tsx

Acceptance criteria

  • Pinning another person's post is refused.
  • Deleting the pinned post clears the pin.
  • The pinned post is not duplicated in the list.
  • Tests for all of the above.

How to work on it

  1. Comment here to claim it, so two people do not do the same work.
  2. Fork the repo and branch from main (feat/short-name or fix/short-name). Setup steps are in docs/DEVELOPMENT.md.
  3. Keep the change focused and add tests for backend logic.
  4. Run npm run typecheck, npm test and npm run lint and npm run format before opening the pull request.
  5. Use a Conventional Commits title (for example feat(web): add bookmarks). More in CONTRIBUTING.md.

Stuck? Ask in this issue. Questions are welcome.


Generated by Claude Code

Dominant language
TypeScript
Stars
6
Forks
6
Avg merge
1h 59m
Merged PRs (30d)
59

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Haseeb-MernStack/commune

All issues in Haseeb-MernStack/commune

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.