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

Refactor ducks #572

Merged
merged 21 commits into from
Nov 12, 2020
Merged

Refactor ducks #572

merged 21 commits into from
Nov 12, 2020

Conversation

ashmaroli
Copy link
Member

No description provided.

src/ducks/config.js Outdated Show resolved Hide resolved
src/ducks/metadata.js Outdated Show resolved Hide resolved
@ashmaroli ashmaroli marked this pull request as ready for review January 8, 2020 07:02
return `${slugifiedTitle}.md`;
};

const validateMetadata = (metadata, collection, directory) => {
Copy link
Member

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.

Copy link
Member Author

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 };
};

@mertkahyaoglu
Copy link
Member

@ashmaroli Is this ready to go?

@ashmaroli ashmaroli merged commit 95493f9 into jekyll:master Nov 12, 2020
@ashmaroli ashmaroli deleted the refactor-ducks branch November 12, 2020 17:13
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