Coder Social home page Coder Social logo

harmishhk / jekyll-sort Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kylepaulsen/jekyll-sort

0.0 2.0 0.0 89 KB

A very simple Jekyll plugin that allows you to sort lists under the site var and store the results back under the site var.

HTML 75.96% Ruby 24.04%

jekyll-sort's Introduction

JekyllSort

Copyright © 2012 Kyle Paulsen. All Rights Reserved.
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)

What is it?

For those of you who have some list and want to sort it in jekyll, this plugin will sort lists of primitives and lists of hashes based on a direction and what to sort on (if needed). It stores the sorted answer in the global site var for usage. If you have lists of hashes of hashes and you want to sort on something deeper than the first level, then you can edit this code.

Usage:

  • Put jekyll_sort.rb in your _plugins directory.
  • Edit your _config.yml to have a jekyll_sort property and make it look something like this:
jekyll_sort:
  - src: numbers
    direction: up
    dest: numbers_sorted
  - src: posts
    by: some_property
    direction: down
    dest: posts_sorted_by_something
  - src: all_content
    by: sort
    direction: down
    dest: all_promoted_by_sort
    include_tags: 
    - promoted
    - news
  • The dash src: attribute specifies what object to sort on. It needs to be in the site var.
  • The by: attribute is for sorting lists of hashes on some hash property. It is only required if you have a list of hashes. Also, you can use an attribute called “sort” which will sort your content arbitrarily by the numeric weight you assign
  • The direction: attribute specifies what direction you want your list to be sorted (up | down). It is only required if you want to sort down. (It is “up” by default)
  • The dest: attribute specifies what site object should hold the sorted list.
  • Posts can be sorted by any property you define in your yaml front matter as well as the properties ‘url’, ‘content’ or ‘date’
  • include_tags: reduce your new collection based on content that includes certain tags
  • Generate your pages like normal! Your sorted lists will be attached to your global site var under their dest attributes for every page.

Update History: (most recent first)

  • 21-Oct-2012 kyle paulsen — allow posts to actually be sorted.
  • 20-Jun-2012 kyle paulsen — First public release.

jekyll-sort's People

Contributors

kylepaulsen avatar hunt3r avatar harmishhk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.