All files / src/lib/content projects.ts

100% Statements 3/3
75% Branches 3/4
100% Functions 3/3
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                2x 6x   3x          
type ProjectLike = {
  data: {
    draft?: boolean;
    order?: number;
  };
};
 
export function getPublicProjects<T extends ProjectLike>(projects: readonly T[]): T[] {
  return projects
    .filter((project) => !project.data.draft)
    .sort(
      (a, b) =>
        (a.data.order ?? Number.MAX_SAFE_INTEGER) -
        (b.data.order ?? Number.MAX_SAFE_INTEGER),
    );
}