Show a list of resources and change url on scolling to a specific resource like Discourse

How to do something like this

Posts index

Post 1

Post 2

Post 3

When a user scrolls to post 1, the url should change from #/posts to #/posts/1, so on.

How should i go about implementing this? Could someone point a resource or an example, please?

You’re looking at an example ;). If you visit this thread which has a lot of posts, you can see that the URL will be updated as you scroll down. I don’t know how exactly they do it, but perhaps you can check the Discourse source code.