Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make all option properties optional #106

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

emmercm
Copy link
Contributor

@emmercm emmercm commented Nov 16, 2023

Attempting to fix some TypeScript typing such that option properties are optional.

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nulls are because the default options use them:

pattern: null,

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root change I want to correct is the ability for pattern to be omitted, such that the collection frontmatter array is used.

Proof it's optional:

if (pattern) {

I think the rest of the properties are optional as well, as I see them all given defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah good catch. I need to check if having the null makes sense. Also, currently developing new major and had to make quite some breaking changes: main...release/2.x.
Still need to wrap my head around some things, like how to make "next" and "previous" references work and how to access "all" vs "own" collections from the metadata

@emmercm emmercm marked this pull request as ready for review November 16, 2023 22:25
@webketje webketje merged commit 0498f4d into metalsmith:main Nov 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants