Interactive tutorials on decentralized web protocols
Blog | Lesson 6 of 7

List posts chronologically with a chain of links

You want to create an overview page that lists your blog posts chronologically.

You could do it the same way as we did with tags. However, you would need to update that page (create a new node) every time you added a new blog post. It sounds wasteful to create a new node with every small change.

There’s a better way! Whenever you create a new blog post, you can link to the previous one directly. This enables you to walk those links to create the chronological overview page dynamically, as we'll see in the next lesson.

We know the CID of a blog post as soon as it is stored in IPFS. We can use that CID to link from newer blog posts to older ones.

Try it!

In the code below, introduce a new field named prev in our blog posts. This field links to the previous blog post.

Link the blog posts in chronological order. The oldest one is the one about trees, then there’s the one about computers. The one about dogs is the latest one. Once you’ve updated them, return the CID of the blog post about dogs.

View SolutionReplace with SolutionClear Default Code
Update the code to complete the challenge. Click Submit to check your answer.