All Projects → ashmaroli → jekyll-data

ashmaroli / jekyll-data

Licence: MIT license
A plugin to read '_config.yml' and data files within Jekyll theme gems

Programming Languages

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

Projects that are alternatives of or similar to jekyll-data

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 (+2965%)
Mutual labels:  jekyll-plugin
Github Metadata
Jekyll plugin to propagate the `site.github` namespace and set default values for use with GitHub Pages.
Stars: ✭ 184 (+360%)
Mutual labels:  jekyll-plugin
jekyll-lazy-tweet-embedding
🐣 A Jekyll plugin to embed the Twitter cards into {.html, .md} pages, by just pasting tweet urls
Stars: ✭ 52 (+30%)
Mutual labels:  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 (+4075%)
Mutual labels:  jekyll-plugin
Jekyll Analytics
Plugin to easily add webanalytics to your jekyll site. Currently Google Analytics, Piwik and mPulse are supported.
Stars: ✭ 166 (+315%)
Mutual labels:  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 (+390%)
Mutual labels:  jekyll-plugin
Jekyll Katex
Jekyll plugin for easy server-side math rendering via KaTeX
Stars: ✭ 73 (+82.5%)
Mutual labels:  jekyll-plugin
easy reader
⏮ ⏯ ⏭ A Rust library for easily navigating forward, backward or randomly through the lines of huge files.
Stars: ✭ 83 (+107.5%)
Mutual labels:  reader
Jekyll Mentions
👥 @mention support for your Jekyll site
Stars: ✭ 176 (+340%)
Mutual labels:  jekyll-plugin
Jekyll Gist
📃 Liquid tag for displaying GitHub Gists in Jekyll sites.
Stars: ✭ 218 (+445%)
Mutual labels:  jekyll-plugin
Jekyll Timeago
⌛️ Ruby library to compute distance of dates in words. Originally built for Jekyll.
Stars: ✭ 130 (+225%)
Mutual labels:  jekyll-plugin
Jekyll Embed Video
Embed videos in Jekyll webpages without a plugin (Youtube, Vimeo, Twitch, Streamable, Mixer, Google Drive clips + more)
Stars: ✭ 135 (+237.5%)
Mutual labels:  jekyll-plugin
Jekyll Minifier
Jekyll HTML/XML/CSS/JS Minifier utilising yui-compressor, and htmlcompressor
Stars: ✭ 215 (+437.5%)
Mutual labels:  jekyll-plugin
Hanuman
A responsive, lightning-fast Jekyll theme built using AMP (Accelerated Mobile Pages) to speed up your blogs and websites.
Stars: ✭ 100 (+150%)
Mutual labels:  jekyll-plugin
MangDL
The most inefficient Manga downloader for PC
Stars: ✭ 40 (+0%)
Mutual labels:  reader
Jekyll Cloudinary
Jekyll plugin adding a Liquid tag for Cloudinary, for better responsive images
Stars: ✭ 79 (+97.5%)
Mutual labels:  jekyll-plugin
Jekyll Remote Theme
Jekyll plugin for building Jekyll sites with any GitHub-hosted theme
Stars: ✭ 188 (+370%)
Mutual labels:  jekyll-plugin
jekyll-extlinks
This Jekyll plugin adds custom attributes (rel="nofollow", target="_blank", etc.) to external links in your content.
Stars: ✭ 18 (-55%)
Mutual labels:  jekyll-plugin
LRReader
A feature-complete reader and client for LANraragi
Stars: ✭ 62 (+55%)
Mutual labels:  reader
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 (+6227.5%)
Mutual labels:  jekyll-plugin

JekyllData

Gem Version Build Status

Introducing a plugin that reads data files within jekyll theme-gems and adds the resulting hash to the site's internal data hash. If a _config.yml is present at the root of the theme-gem, it will be evaluated and the extracted hash data will be incorporated into the site's existing config hash.

Installation

Simply add the plugin to your site's Gemfile and config file like every other jekyll plugin gem:

# Gemfile

group :jekyll_plugins do
  gem "jekyll-data"
end

..and run

bundle install

Note: If the plugin has been marked as a runtime_dependency by the theme-gem's author it will be installed automatically with the theme-gem. Yet, it is recommended that the plugin be added to :jekyll_plugins group in the Gemfile rather than the gems: array in the config file while building or serving the site to avoid 'overriding' the gems: array data that may have been read-in from the theme-gem.

Usage

As long as the plugin-gem has been installed properly, and is included in the Gemfile's :jekyll_plugins group, data files supported by Jekyll and present in the _data directory at the root of your theme-gem will be read. Their contents will be added to the site's internal data hash, provided, an identical data hash doesn't already exist at the site-source.

If the theme-gem also includes a _config.yml at its root, then it will be read as well. The resulting config hash will be mixed into the site's existing config hash, filling in where the keys are not already defined. In other words, the config file at source will override corresponding identical keys in a _config.yml within the theme-gem which would in turn override corresponding DEFAULTS from Jekyll:

DEFAULTS < _config.yml in theme-gem < _config.yml at source < Override configs via command-line.

Theme Configuration

Jekyll themes (built prior to Jekyll 3.2) usually ship with configuration settings defined in the config file, which are then used within the theme's template files directly under the site namespace (e.g. {{ site.myvariable }}). This is not possible with theme-gems as a config file and data files within gems are not natively read (as of Jekyll 3.3), and hence require end-users to inspect a demo or example directory to source those files.

This plugin provides a solution to that hurdle:

JekyllData now reads the config file (at present only _config.yml) present within the theme-gem and uses the data to modify the site's config hash. This allows the theme-gem to continue using {{ site.myvariable }} within its templates and work out-of-the-box as intended, with minimal user intervention.

Note: the plugins required by the theme may be listed under the gems: array and will be automatically required by Jekyll while building/serving, provided that the user doesn't have a different gems: array in the config file at source. Hence it is recommended to add all other plugins ( including jekyll-data ) via the Gemfile's :jekyll_plugins group.

The theme namespace

From v1.0, JekyllData no longer supports reading theme configuration provided as a [theme-name].*** file within the _data directory and instead the theme namespace points to a certain key in the bundled _config.yml.

For {{ theme.variable }} to work, the config file should nest all such key-value pairs under the [theme-name] key, as outlined in the example below for a theme-gem called solitude:

# <solitude-0.1.0>/_config.yml

# the settings below have been used in this theme's templates via the `theme`
# namespace. e.g. `{{ theme.recent_posts.style }}` instead of using the more
# verbose `{{ site.solitude.recent_posts.style }}` though both are functionally
# the same.
#
solitude:
  sidebar       : true      # enter 'false' to enable horizontal navbar instead.
  theme_variant : Charcoal  # choose from 'Ocean', 'Grass', 'Charcoal'
  recent_posts  :
    style       : list      # choose from 'list' and 'grid'.
    quantity    : '4'       # either '4' or '6'

Data files

Data files may be used to supplement theme templates (e.g. locales and translated UI text) and can be named as desired.

  • Organize related small data files in sub-directories. (or)
  • Declare all related data as mapped data blocks within a single file.

To illustrate with an example, consider a locales.yml that has mappings for en:, fr:, it:.

# <theme-gem>/_data/locales.yml

en:
  previous : previous
  next     : next

fr:
  previous : précédent
  next     : prochain

it:
  previous : precedente
  next     : successivo

the Hash from above would be identical to one had the gem been shipped with a _data/locales directory containing individual files for each language data.

Overriding Data Files

To override data shipped with a theme-gem, simply have an identical hash at the site-source.

Irrespective of whether the theme-gem ships with consolidated data files of related entities, or sub-directories containing individual files, the data can be overridden with a single file or with multiple files.

For example, if a theme-gem contains the above sample locales.yml, then to override the fr: key-data simply have either of the following:

  • a _data/locales/fr.yml with identical subkey(s).
  • a _data/locales.yml with fr: with identical subkey(s).

--

Note

  • having an empty _data/locales.yml at source directory will override the entire ["data"]["locales"] payload from the theme-gem as false.
  • having an empty _data/locales/fr.yml at source directory will override the enire ["data"]["locales"]["fr"] payload from the theme-gem as false

Contributing

Bug reports and pull requests are welcome at the GitHub Repo. 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.

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].