-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Refactor ducks #572
Refactor ducks #572
Conversation
src/ducks/collections.js
Outdated
return `${slugifiedTitle}.md`; | ||
}; | ||
|
||
const validateMetadata = (metadata, collection, directory) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not just validating metadata but also mutating path
. I don't think we should mix things here. In order to understand what this function does to path, we need to look into it. It seems not write to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what would be the best way to proceed yet avoid repeating the following logic in every duck (that handles metadata
)?
const validateMetadata = (metadata, directory) => {
let { path, title } = metadata;
let errors = [];
if ((!path || `${path}/` === directory) && title) {
path = getFilenameFromTitle(title);
} else {
errors = validatePage(metadata);
}
return { path, errors };
};
81a6ac0
to
e3c98e2
Compare
9425bc0
to
6e6eaed
Compare
@ashmaroli Is this ready to go? |
No description provided.