Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
jekyll-contentblocks
Advanced tools
Gives you a mechanism in Jekyll to pass content up from pages into their parent layouts. It's kind of like having Rails' content_for available for Jekyll.
Add this line to your Jekyll project's Gemfile
:
group :jekyll_plugins do
gem 'jekyll-contentblocks'
end
Then execute:
$ bundle install
Execute:
$ gem install jekyll-contentblocks
And initialize it in a plugin:
# _plugins/ext.rb
require "rubygems"
require "jekyll-contentblocks"
In your layout files, define contentblock
blocks that say where content will
end up. For example, say the file _layouts/default.html
looks like this:
<html>
<head>
{% contentblock scripts %}
</head>
<body>
<div class="main">
{{ content }}
</div>
<div class="sidebar">
{% contentblock sidebar %}
</div>
</body>
</html>
Now to add content to the sidebar from a post, you'd just need to do something like:
---
layout: default
---
Here is my post content.
{% contentfor sidebar %}
* Some content
* in a markdown list
* with some {{ 'liquid' }} tags too!
{% endcontentfor %}
Note that we didn't add anything to the scripts
block in the post. That's OK,
content blocks without any content will be ignored.
By default, a content block will be run through the converter for the current
file (Markdown, for instance). Sometimes this is not desirable, such as for
blocks containing code that shouldn't be modified. In the example above, content
in the scripts
block will be converted by default. To prevent this, add the
no-convert
option to the block, like this:
{% contentblock scripts no-convert %}
Now any content added to scripts
will be placed in the block without any
formatting applied.
We might want to check if the particular contentblock has content before using
it in our template. To do this, use the ifhascontent
tag:
{% ifhascontent javascripts %}
<script type="text/javascript>
{% contentblock javascripts %}
</script>
{% endifhascontent %}
Similarly, there's the opposite tag, ifnothascontent
:
{% ifnothascontent sidebar %}
<div>
This is our default sidebar.
</div>
{% endifnothascontent %}
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Try to make sure that your changes work with all of the latest point releases of Jekyll. To do this, run the test suite:
> bundle
> bundle exec appraisal install
> bundle exec appraisal rpsec
FAQs
Unknown package
We found that jekyll-contentblocks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.