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

Use custom classifications like tags & categories #670

Closed
wants to merge 3 commits into from

Commits on May 22, 2014

  1. 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
    ```
    goodtouch committed May 22, 2014
    Configuration menu
    Copy the full SHA
    de5a9b1 View commit details
    Browse the repository at this point in the history
  2. Add unit tests

    goodtouch committed May 22, 2014
    Configuration menu
    Copy the full SHA
    c8bc63f View commit details
    Browse the repository at this point in the history
  3. Add cucumber test

    goodtouch committed May 22, 2014
    Configuration menu
    Copy the full SHA
    7966ada View commit details
    Browse the repository at this point in the history