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

Build a tag cloud with arrays of links

A single object can have many links to other nodes. To illustrate this, let's create new nodes which could be used for a tag cloud.

Until now, we've been using named links, meaning that we create a named field with a single link as its value, such as:

  author: samCid

However, we can also choose to gather links into an array without naming each one individually.

  links: [natCid, samCid]

This is perfect for our use case, where a single tag should be associated with many posts, like so:

  tag: "name-of-the-tag",
  posts: [/* links to the CIDs */]

Please note that arrays are order-dependent. This means that two arrays with the same links in a different order will get different CIDs.

Try it!

Create new nodes for the tags outdoor and hobby in the format shown above, linking to the relevant blog posts using arrays. Insert the new tag objects into IPFS via ipfs.dag.put and return the two resulting CIDs as an array.

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