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

848 hierarchical categories #2734

Merged
merged 6 commits into from
Sep 5, 2017
Merged

848 hierarchical categories #2734

merged 6 commits into from
Sep 5, 2017

Conversation

danieljsummers
Copy link
Contributor

This implements the ability to have multiple category hierarchies attached to a single post (#848).

By default, everything works the way it currently does; a list of categories will be assembled for a single category hierarchy. The change implemented here is that, if a category is a list, setCategories() will switch into multiple category mode, and each top-level item in the list will be a category hierarchy itself.

categories:
- Example 1
- Example 2
- [Example 3, Subexample 3.1]

This will result in four different categories assigned to the post, with three different hierarchies (example-1, example-2, and example-3/subexample-3.1). The category generator already created index pages for intermediate categories, so [url]/category/example-3/ is a good URL, and would contain this post.

I have just forked/cloned the site repo, and will get the documentation for this change there. Additionally, I plan to look at the WordPress export format; if it exports the categories in their hierarchy, I'll see if I can PR a change to that migrator to bring the hierarchies over intact.

  • Add test cases for the changes.
  • Passed the CI test.

The code still needs some cleanup, but the new test passes without
breaking the old ones.
added tests for category list and front-matter processor to include
multiple categories; cleaned up Post.setCategories() code
@coveralls
Copy link

coveralls commented Aug 30, 2017

Coverage Status

Coverage increased (+0.006%) to 97.164% when pulling 3f45e26 on danieljsummers:848-hierarchical-categories into dfb5a4b on hexojs:master.

@danieljsummers
Copy link
Contributor Author

No fat arrow functions, huh? :) I'll have that pushed up momentarily.

CodeClimate didn't like 'em...
@coveralls
Copy link

coveralls commented Aug 30, 2017

Coverage Status

Coverage increased (+0.006%) to 97.164% when pulling a57f3c1 on danieljsummers:848-hierarchical-categories into dfb5a4b on hexojs:master.

@NoahDragon
Copy link
Member

Add reference #848

@NoahDragon NoahDragon added the enhancement New feature or request label Aug 30, 2017
@danieljsummers
Copy link
Contributor Author

I realized that I didn't check for duplicate parents not being added. I wrote a test to check for that, and it passed with no code changes. I'll commit the test to this branch.

ensure we do not create a duplicate post/category xref for duplicate
parent categories
@coveralls
Copy link

coveralls commented Aug 30, 2017

Coverage Status

Coverage increased (+0.006%) to 97.164% when pulling ce337a3 on danieljsummers:848-hierarchical-categories into dfb5a4b on hexojs:master.

@danieljsummers
Copy link
Contributor Author

FWIW, the code here enabled me to move my tech blog, which is live here!

Copy link
Member

@NoahDragon NoahDragon left a comment

Choose a reason for hiding this comment

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

LGTM

@NoahDragon
Copy link
Member

@danieljsummers The live sample is really cool. This is also a major feature will in 4.0. #2492

Thanks for the contribution!

@NoahDragon NoahDragon mentioned this pull request Sep 5, 2017
53 tasks
@NoahDragon
Copy link
Member

Add reference: need to update hexo site when the feature released. hexojs/site#550

@NoahDragon NoahDragon merged commit d27b704 into hexojs:master Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants