Is your feature request related to a problem? Please describe.
I would like to be able to display a collection of pages (e.g. my latest blog posts or an alphabetized list of API docs).
VuePress has $site.pages
, but VitePress does not ship metadata about all pages, which is great except when I need that data for certain pages.
Describe the solution you'd like
I would like to specify collections of pages that I need metadata for in config.js, for example:
module.exports = {
title: "My Tech Blog",
collections: [
{
name: 'blog',
directory: '_posts/',
layout: 'BlogPostLayout',
},
{
name: 'api',
directory: 'guide/api/',
layout: 'TechDocLayout',
}
],
};
This would produce an array of metadata for pages inside the _posts directory could then be accessed via $site.collections.blog
I've also included a layout option that could be used to define a default layout for pages in that collection. That's a separate idea, but the point is that collections could have additional benefits.
You could possibly specify which metadata you need - e.g. you may or may not need the frontmatter for every page in the collection.
I've borrowed the term "collections" from NetlifyCMS, which I use with VuePress currently.
Describe alternatives you've considered
Alternatively, you could simply have a config option to ship metadata for all pages, but that would be all or nothing.
Additional context
Here's an example of how I've implemented collections in a VuePress theme: themeConfig.js, PostList.vue, GlobalLayout.vue