Giter VIP home page Giter VIP logo

hackernews-next's Introduction

Hackernews in Nextjs

This is a project I created out of my own interest to learn more about Nextjs app router, React Server Components and styling with tailwindcss and shadcn. I have also challenged myself to make the website responsive on mobile as well. The web app is currently deployed on vercel.

Tech stack used

Running locally

The usual way

git clone https://github.com/WilsonOh/hackernews-next.git
npm i
npm run dev

Docker

git clone https://github.com/WilsonOh/hackernews-next.git
docker build -t <your image name>:<your tag> .
docker run -p 3000:3000 -d <your image name>:<your tag>

Screenshots

Desktop image image
Mobile image image

Features

  • Dark/Light mode toggle
  • Infinite/Paginated view toggle
  • Mobile-first design

Roadmap

  • Pages for each stories category (best, new, job etc.)
  • Card view of items for each stories page with pagination
  • Item page with collapsible comments
  • Mobile responsive view for stories page and item page
  • Go between sibling/parent/root nodes in the comments (similar to the original hackernews website)
  • Sorting of stories by score, number of comments, date created etc.
  • Filtering of stories by score, date created, date range etc.
  • Implement bookmarking of items using local storage (probably not gonna use/host a DB for this)

Not going to do (probably)

  • Implement the user page
  • Implement search
  • Anything that requires authentication like logging in, voting, posting etc. (since there's no official API support) Still might do this in the future with NextAuth though

Credits

hackernews-next's People

Contributors

wilsonoh avatar

Stargazers

 avatar

Watchers

 avatar

hackernews-next's Issues

Maintain a database of all the post items for easier filtering/sorting operations

Background

Currently, each story category (top/best/jobs etc.) returns at most 500 entries. Sorting and filtering through those entries is quite fast. However, I want to be able to sort/filter through every single post since the beginning. In order to do so using hackernews APIs, I would need to retrieve every single item from id=${maxItem} to id=0. Having to do this every time a user wants to view posts sorted in descending order by the number of votes for example would be too inefficient and wasteful. Therefore, having a database for this will minimize the number of API calls that will be made.

A caching layer (redis) can also be used to cache the sorted/filtered items so that we don't have query the database constantly. The entries can be set to have a TTL=1hr

Tasks

  • Set up a database (most likely an RDB) with the Tables/Documents modelled after the hackernews API models
  • Seed the database with initial data (insert every item into the database from the current id=maxItem to id=0
  • Set up redis as the caching layer between the database and the webapp
  • Wire up the data retrieval, sorting and filtering functionality using a repository layer within the nextjs app, using an SQL query builder if possible instead of an ORM
  • Update the UI for the additional functionality

Acceptance Criteria

  • A user is able to view the highest rated posts of all time/last week/last month/last year etc. similar to reddit. The ranking will be based on the last updated value (retrieved from the redis cache or otherwise)
  • A user is able to sort posts by votes/number of comments/date created in various time periods - all time/last week/last month etc.
  • A user is able to view all posts by a certain user (possible with a RDB)
  • A user is able to sort/filter posts within an arbitrary time frame. This operation can't really be cached in contrast with the "preset" time periods as mentioned above, so it will take a longer time to process

Additional notes

  • AWS Elastic Cache can be considered as the redis solution
  • PlanetScale can be considered as the RDB solution
  • tRPC can be used to make the DB calls type-safe through Nextjs API routes

Implement alternative page view with infinite scrolling for the story list

Background

Currently, hackernews-next uses a paginated model to display stories. This model works well but some users may want to have infinite scrolling instead. This would provide a smoother user experience and make the navigation of the site more intuitive.

Tasks:

  • Look into useSWRInfinite to implement infinite scrolling
  • Use query/path params to separate the paginated view and infinite scrolling view
  • Test the infinite scrolling using playwright

Completion Criteria

  • Given I'm on the infinite scrolling page view for the stories list
  • And I scroll to the bottom of the page
  • Then I should see a loading spinner at the bottom of the page, after which the next page of stories will be rendered. If there are no more stories, I should see an indicator/alert which tells me that there are no more stories.

Show option popover when clicking on hackernews links within comments/post content

Background

Currently, hackernews links within comments or posts will open in the original hackernews website (naturally). This might disrupt the user experience of hackernews-next if the user wants to continue browsing other hackernews items on the same website.

Tasks

  • using the replace/transform option in react-html-parser, replace all <a> tags where the URI starts with news.ycombinator.com/item with a custom link component.
  • set up the custom link component such that clicking it will trigger a popover, presenting the user with 2 choices - go to the original link or view the item in hackernews-next

Acceptance Criteria

  • Upon clicking a link matching news.ycombinator.com/item in comments or posts, a popover will be triggered, allowing the user to choose between going to news.ycombinator.com/item or hn.oyxw.xyz/item

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.