text: const dayjs = require("dayjs");
  
  function getByDate(collection, dateFormat) {
    let postsByDate = {};
    let posts = collection.getFilteredByGlob(["./src/content/articles/**/*.md"]);
    posts.forEach(function (post) {
      if (!post.data.date) {
        return;
      }
      let d = dayjs(post.data.date).format(dateFormat);
      if (!postsByDate[d]) {
        postsByDate[d] = new Array();
      }
      postsByDate[d].push(post);
    });
    return postsByDate;
  }
  
  // Collections: Posts by year
  exports.postsByYear = (collection) => {
    return getByDate(collection, "YYYY");
  };
  
  // Collections: Posts
  exports.posts = (collection) => {
    return collection.getFilteredByGlob(["./src/content/articles/**/*.md"]);
  };
  
  // Collections: Featured Posts
  exports.featured = (collection) => {
    return collection
      .getFilteredByGlob(["./src/content/articles/**/*.md"])
      .filter((item) => item.data.featured)
      .sort((a, b) => b.date - a.date);
  };
  
  // Collections: Pages
  exports.pages = (collection) => {
    return collection.getFilteredByGlob(["./src/content/pages/*.md"]);
  };
  