Site | Gem Page | GitHub Repo
Meet jekyll-uj-powertools, your new best friend for developing with Ultimate jekyll
🦄 Features
- Powerful utility for Jekyll sites
uj_strip_adsfilter to remove ads from a stringuj_json_escapefilter to escape JSON characters
🌐 Jekyll::uj-powertools
Meet jekyll-uj-powertools, the powerful set of utilities for Jekyll users.
It includes functions to remove ads from strings and escape JSON characters, making your Jekyll site cleaner and more efficient.
📦 Installation
Install the gem and add to the application's Gemfile by executing:
bundle add jekyll-uj-powertools
If bundler is not being used to manage dependencies, install the gem by executing:
gem install jekyll-uj-powertools
⚡️ Usage
Now you can use all the custom filters and variables provided by jekyll-uj-powertools in your Jekyll site.
Filters
uj_strip_ads Filter
Remove ads from a string, such as a blog post or article.
{{ post.content | uj_strip_ads }}
uj_json_escape Filter
Escape JSON characters in a string making it safe to use in a JSON object.
{{ post.content | uj_json_escape }}
uj_title_case Filter
Convert a string to title case.
{{ "hello world" | uj_title_case }}
Global Variables
site.uj.cache_breaker Variable
Use the site.uj.cache_breaker variable to append a cache-busting query parameter to your assets.
<link rel="stylesheet" href="{{ "/assets/css/style.css" | prepend: site.baseurl }}?v={{ site.uj.cache_breaker }}">
Page Variables
page.random_id Variable
Generate a random ID for each page, useful for sorting randomly or for unique identifiers.
<!-- Sort pages in a random order -->
{% assign sorted_pages = site.pages | sort: "random_id" %}
{% for page in sorted_pages %}
<h2>{{ page.title }}</h2>
<p>Random ID: {{ page.random_id }}</p>
<p>{{ page.content }}</p>
{% endfor %}
page.extension Variable
Get the file extension of the current page, useful for determining how to process or display the page.
<!-- Check the extension of a page -->
{% if page.extension == "html" %}
<p>This is an HTML page.</p>
{% elsif page.extension == "md" %}
<p>This is a Markdown page.</p>
{% endif %}
page.layout_data Variable
Access the layout data of the page object, which can be useful for accessing layout-specific variables when looping through pages.
<!-- Loop through pages and access the layout data of each page -->
{% for page in site.pages %}
<h2>{{ page.title }}</h2>
<p>{{ page.layout_data.description }}</p>
{% endfor %}
page.resolved Variable
Resolves the site, layout, and page data into a single object, which can be useful for accessing all the information about the current page in one place.
<!-- New Way -->
{{ page.resolved.my.variable }}
<!-- Old Way -->
{{ page.my.variable | default: layout.my.variable | default: site.my.variable }}
These examples show how you can use the features of jekyll-uj-powertools in your Jekyll site.
🔧 Development
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install.
To release a new version, update the version number in the .gemspec and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
⚠️ Testing
Run the tests
bundle install
bundle exec rspec
💎 Build + Publish the Gem
# Release
bundle exec rake release
# Clear the files in the pkg folder
rm -rf pkg/*
🗨️ Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/itw-creative-works/jekyll-uj-powertools.
📚 Projects Using this Library
Ask us to have your project listed! :)