All Projects → ibrado → jekyll-stickyposts

ibrado / jekyll-stickyposts

Licence: MIT License
Jekyll Stickyposts - move selected posts to the top of the list

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to jekyll-stickyposts

Jekyll Timeago
⌛️ Ruby library to compute distance of dates in words. Originally built for Jekyll.
Stars: ✭ 130 (+465.22%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Spaceship
🚀 A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, mermaid, emoji, video, audio, youtube, vimeo, dailymotion, soundcloud, spotify, etc.
Stars: ✭ 196 (+752.17%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Embed Video
Embed videos in Jekyll webpages without a plugin (Youtube, Vimeo, Twitch, Streamable, Mixer, Google Drive clips + more)
Stars: ✭ 135 (+486.96%)
Mutual labels:  jekyll, jekyll-plugin
jekyll-pwa
Jekyll plugin for PWA
Stars: ✭ 95 (+313.04%)
Mutual labels:  jekyll, jekyll-plugin
jekyll-imgix
A plugin for integrating imgix into Jekyll sites
Stars: ✭ 49 (+113.04%)
Mutual labels:  jekyll, jekyll-plugin
Hanuman
A responsive, lightning-fast Jekyll theme built using AMP (Accelerated Mobile Pages) to speed up your blogs and websites.
Stars: ✭ 100 (+334.78%)
Mutual labels:  jekyll, jekyll-plugin
Github Metadata
Jekyll plugin to propagate the `site.github` namespace and set default values for use with GitHub Pages.
Stars: ✭ 184 (+700%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Katex
Jekyll plugin for easy server-side math rendering via KaTeX
Stars: ✭ 73 (+217.39%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Gist
📃 Liquid tag for displaying GitHub Gists in Jekyll sites.
Stars: ✭ 218 (+847.83%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Admin
A Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites.
Stars: ✭ 2,531 (+10904.35%)
Mutual labels:  jekyll, jekyll-plugin
jekyll-manager
A repackaged Jekyll Admin fork with some alterations.
Stars: ✭ 48 (+108.7%)
Mutual labels:  jekyll, jekyll-plugin
jekyll-pwa-workbox
A Jekyll plugin using Workbox to make your PWA / Website available offline.
Stars: ✭ 22 (-4.35%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Seo Tag
A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
Stars: ✭ 1,226 (+5230.43%)
Mutual labels:  jekyll, jekyll-plugin
Pages Gem
A simple Ruby Gem to bootstrap dependencies for setting up and maintaining a local Jekyll environment in sync with GitHub Pages
Stars: ✭ 1,670 (+7160.87%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Cloudinary
Jekyll plugin adding a Liquid tag for Cloudinary, for better responsive images
Stars: ✭ 79 (+243.48%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Analytics
Plugin to easily add webanalytics to your jekyll site. Currently Google Analytics, Piwik and mPulse are supported.
Stars: ✭ 166 (+621.74%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Scholar
jekyll extensions for the blogging scholar
Stars: ✭ 872 (+3691.3%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Minibundle
A minimalistic asset bundling plugin for Jekyll
Stars: ✭ 65 (+182.61%)
Mutual labels:  jekyll, jekyll-plugin
Jekyll Minifier
Jekyll HTML/XML/CSS/JS Minifier utilising yui-compressor, and htmlcompressor
Stars: ✭ 215 (+834.78%)
Mutual labels:  jekyll, jekyll-plugin
japr
Jekyll Asset Pipeline Reborn - Powerful asset pipeline for Jekyll that collects, converts and compresses JavaScript and CSS assets.
Stars: ✭ 52 (+126.09%)
Mutual labels:  jekyll, jekyll-plugin

Jekyll::StickyPosts

Gem Version

StickyPosts is a plugin for Jekyll that sticks/pins posts marked sticky: true to the top, i.e. it moves them before all others. Optionally, the posts could also appear where they normally would.

Why do this?

  1. You want to keep important announcements, etc. at the top of your home page
  2. You want descriptive entries to appear at the top of your collections

What's new?

v1.2.2 Allow inclusion in _config.yml plugins

v1.2.1 Fix sorting

v1.2.0 Add reverse_sticky option

v1.1.0 Support multiple collections

Installation

Add the gem to your application's Gemfile:

group :jekyll_plugins do
  # other plugins here
  gem 'jekyll-stickyposts'
end

And then execute:

$ bundle

Or install it yourself:

$ gem install jekyll-stickyposts

Configuration

No configuration is required to run StickyPosts. If you want to tweak its behavior, you may set the following options in _config.yml:

stickyposts:
  #enabled: false   # Enable StickyPosts; default: true
  debug: true       # Show additional info; default: false
  sort: "blah"      # Optional sort field; default: "date", use "none" to avoid sorting
  reverse: true     # Ascending order, default: false
  retain: true      # Also show sticky posts in their original positions; default: false
  reverse_sticky: true    # Reverse the order of the sticky posts, e.g. oldest first; default: false

  #collection: articles   # The collection to "stickify"; default "posts"

  # Or multiple collections:
  #collections:
  # - posts
  # - articles

  # Same thing:
  #collections: ["posts", "articles"]

Note: if you set sort to "none" and don't sort as described in the next section, Jekyll will re-sort the documents by date. This will likely move the sticky posts out of position.

Usage

Just add a sticky: true entry to your front matter:

---
title: Test
date: 2017-12-15 22:33:44
sticky: true
---

If you're not using a paginator at all, use something like:

{% assign sorted = site.posts | sort: "stickiness" %}
{% for post in sorted %}
...etc...
{% endfor %}

If you're using the original jekyll-paginate:

{% assign sorted = paginator.posts | sort: "stickiness" %}
{% for post in sorted %}
...etc...
{% endfor %}

If you're using a paginator that allows sorting on fields, e.g. jekyll-paginate-v2, you need to edit your _config.yml a bit:

pagination:
  # ...
  sort_field: "stickiness"
  sort_reverse: false
  # ...

# ...etc...

stickyposts:
  sort: "date"   # or your original pagination sort_field
  #reverse: true  #  ditto for the sort_reverse
  # ...etc...

No changes will be required in your pagination setup:

{% for post in paginator.posts %}
...etc...
{% endfor %}

Miscellany

You may want to mark sticky posts with e.g. a pin from FontAwesome:

{% if post.sticky %}
  <span class="sticky"><i class="fa fa-thumb-tack" aria-hidden="true"></i></span>
{% endif %}

Or, if you want to put a header/descriptive post at the top of your collections:

{% if post.sticky %}
  # Formatting for the header
{% else %}
  # Formatting for normal entries
{% endif %}

Or similarly:

{% unless post.sticky %}
  # Meta information for the entry
{% endunless %}
  # The rest of the entry description, e.g. excerpt

Demo

See the author's blog for a (possible) demo.

Contributing

  1. Fork this project: https://github.com/ibrado/jekyll-stickyposts/fork
  2. Clone it (git clone git://github.com/your_user_name/jekyll-stickyposts.git)
  3. cd jekyll-stickyposts
  4. Create a new branch (e.g. git checkout -b my-bug-fix)
  5. Make your changes
  6. Commit your changes (git commit -m "Bug fix")
  7. Build it (gem build jekyll-stickyposts.gemspec)
  8. Install and test it (gem install ./jekyll-stickyposts-*.gem)
  9. Repeat from step 5 as necessary
  10. Push the branch (git push -u origin my-bug-fix)
  11. Create a Pull Request, making sure to select the proper branch, e.g. my-bug-fix (via https://github.com/*your_user_name*/jekyll-stickyposts)

Bug reports and pull requests are welcome on GitHub at https://github.com/ibrado/jekyll-stickyposts. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Jekyll::StickyPosts project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Also by the author

Jekyll Tweetsert Plugin - Turn tweets into Jekyll posts. Multiple timelines, filters, hashtags, automatic category/tags, and more!

Jekyll::Paginate::Content - Split your Jekyll pages, posts, etc. into multiple pages automatically. Single-page view, pager, SEO support, self-adjusting links, multipage-aware Table Of Contents.

Jekyll::ViewSource - Generate pretty or plain HTML and/or Markdown source code pages.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].