Skip to content

Commit

Permalink
Fix: make all option properties optional
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored and webketje committed Nov 25, 2024
1 parent b5b8059 commit b85b6cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ export type CollectionConfig = {
/**
* - One or more glob patterns to match files to a collection
*/
pattern: string | string[];
pattern?: string | string[] | null;
/**
* - A key to sort by (e.g. `date`,`title`, ..) or a custom sort function
*/
sortBy: string | ((a: any, b: any) => 0 | 1 | -1);
sortBy?: string | ((a: any, b: any) => 0 | 1 | -1);
/**
* - Limit the amount of items in a collection to `limit`
*/
limit: number;
limit?: number;
/**
* - Adds `next` and `previous` keys to file metadata of matched files
*/
refer: boolean;
refer?: boolean;
/**
* - Whether to invert the sorting function results (asc/descending)
*/
reverse: boolean;
reverse?: boolean;
/**
* - A function that gets a `Metalsmith.File` as first argument and returns `true` for every file to include in the collection
*/
filterBy: Function;
filterBy?: Function;
/**
* - An object with metadata to attach to the collection, or a `json`/`yaml`filepath string to load data from (relative to `Metalsmith.directory`)
*/
metadata: any | string;
metadata?: any | string | null;
};
/**
* Add `collections` of files to the global metadata as a sorted array.
Expand Down
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const defaultFilter = () => true

/**
* @typedef {Object} CollectionConfig
* @property {string|string[]} pattern - One or more glob patterns to match files to a collection
* @property {string|(a,b) => 0|1|-1} sortBy - A key to sort by (e.g. `date`,`title`, ..) or a custom sort function
* @property {number} limit - Limit the amount of items in a collection to `limit`
* @property {boolean} refer - Adds `next` and `previous` keys to file metadata of matched files
* @property {boolean} reverse - Whether to invert the sorting function results (asc/descending)
* @property {Function} filterBy - A function that gets a `Metalsmith.File` as first argument and returns `true` for every file to include in the collection
* @property {Object|string} metadata - An object with metadata to attach to the collection, or a `json`/`yaml`filepath string to load data from (relative to `Metalsmith.directory`)
* @property {string|string[]} [pattern] - One or more glob patterns to match files to a collection
* @property {string|(a,b) => 0|1|-1} [sortBy] - A key to sort by (e.g. `date`,`title`, ..) or a custom sort function
* @property {number} [limit] - Limit the amount of items in a collection to `limit`
* @property {boolean} [refer] - Adds `next` and `previous` keys to file metadata of matched files
* @property {boolean} [reverse] - Whether to invert the sorting function results (asc/descending)
* @property {Function} [filterBy] - A function that gets a `Metalsmith.File` as first argument and returns `true` for every file to include in the collection
* @property {Object|string} [metadata] - An object with metadata to attach to the collection, or a `json`/`yaml`filepath string to load data from (relative to `Metalsmith.directory`)
*/

/** @type {CollectionConfig} */
Expand Down

0 comments on commit b85b6cf

Please sign in to comment.