Complete the code to query all entries from the 'posts' collection.
const posts = Astro.[1]('posts');
The Astro.getCollection function is used to get all entries from a collection by its name.
Complete the code to filter entries from the 'posts' collection where the slug equals 'welcome'.
const welcomePost = Astro.getCollection('posts').filter(post => post.data.slug [1] 'welcome');
The strict equality operator === checks if the slug exactly matches 'welcome'.
Fix the error in the code to correctly get the first entry from the 'authors' collection.
const firstAuthor = Astro.getCollection('authors').[1](0);
The at(0) method returns the first element of an array in JavaScript.
Fill both blanks to create a dictionary of post titles keyed by their slugs for posts with more than 100 views.
const popularPosts = Object.fromEntries( Astro.getCollection('posts') .filter(post => post.data.views [1] 100) .map(post => [post.data.[2], post.data.title]) );
We filter posts with views greater than 100 using > and use the slug as the key in the dictionary.
Fill all three blanks to create a filtered dictionary of uppercase author names keyed by their IDs for authors with verified status.
const verifiedAuthors = Object.fromEntries( Astro.getCollection('authors') .filter(author => author.data.[1] === true) .map(author => [author.data.[2], author.data.name.[3]()]) );
The filter checks the 'verified' property for true, keys by 'id', and converts the name to uppercase using toUpperCase().
