Skip to content

Instantly share code, notes, and snippets.

View mmistakes's full-sized avatar

Michael Rose mmistakes

View GitHub Profile
@mmistakes
mmistakes / rename_comments.rake
Last active October 24, 2016 15:52
Rename comment data files eg: comment-2014-01-21013323.yml ~>comment-1390268003000.yml
require "bundler/setup"
require "fileutils"
require "date"
require "time"
## -- Misc Configs -- ##
source_dir = "src" # source file directory
comments_dir = "_data/comments/sub-folder-name" # comment directory
comment_label = "comment-"
@mmistakes
mmistakes / markdown-img-picture-replacement.rb
Last active April 28, 2024 11:16
Jekyll plugin to replace Markdown images eg. `![description](image.jpg)` with `{% picture %}` tag
# Description: Jekyll plugin to replace Markdown image syntax with {% picture %} tag for crafting responsive images
# place in /_plugins/
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
docExt = post.extname.tr('.', '')
# only process if we deal with a markdown file
if payload['site']['markdown_ext'].include? docExt
newContent = post.content.gsub(/\!\[(.+)\]\((.+)\)/, '{% picture default \2 alt="\1" %}')
post.content = newContent
end
{% capture the_collection %}{{ page.collection }}{% endcapture %}
{% if page.collection %}
{% assign document = site[the_collection] %}
{% endif %}
{% for links in document %}
{% if links.title == page.title %}
{% unless forloop.first %}
{% assign prevurl = prev.url %}