forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use custom classifications (tags, categories, ...)
We used to classify posts with tags & categories. This patch adds a generic way to define & use your own classifications through `site.config[:classifications]` by adding `tags` like behavior to site & posts for added classifications. Let's say you want classify Post by referring to Project(s), Customer(s) and Layout(s) you can now simply add the following to `_config.yml` : ``` classifications: - projects - customers - layouts ``` And start using those classifications like you would with `categories` or `tags` : Add the following to a Post: ``` projects: - project1 - project2 layout: - grid - responsive ``` And then use the following in any template : ``` <h2>Projects</h2> <ul> {% for project in site.projects %} <li>{{ project | first }}</li> {% endfor %} </ul> ``` You can also access classifications through `classifications` methods of `Site` and `Post` if you're not in a Liquid template context (ie. when writting a Jekyll plugin) : ``` module Jekyll class CustomGenerator def generate(site) related_layouts = {} site.classifications['projects'].each do |project, posts| related_layouts[project] = posts.map{ |post| post.classifications['layouts'] }.flatten end # ... end end end ```
- Loading branch information
Showing
5 changed files
with
98 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters