frontity.state.source.get('/')
that there was an array of items
which were the posts to display on the homepage. Let's now use that array to display some basic information about each of the posts in our browser.components
directory and call it list.js
.<List>
which will first get the data for the current URL (remember that this is stored in state.router.link
) using the get
helper function. It will then use JavaScript's array.map
method to iterate over the items
array and display the type
, id
and link
of each post.frontity.state.source.get('/')
in the browser's console.<List>
component into our root component file and use it.Home
page and on the More posts
page.<List>
component to get the information about each of the posts and show the title and turn it into a link.items
array.items
array for the homepage has a number of posts, the first of which is of type post
and has the id
60.state.source.post[60]
where we can get the title and the link for that post.items
array, and as we iterate over each item in the array (using array.map
) we get the post content for each post with:post
that we could instead use:type
property stored in the data rather than hard code the type. In this case all the items are indeed of type post
, but that's not necessarily always the case - sometimes we'll work with pages, or attachment images, or even custom post types, etc...list.js
file is going to look like:<Link>
component into list.js
!