Skip to content

Instantly share code, notes, and snippets.

View sskylar's full-sized avatar
lgtm

Skylar SC sskylar

lgtm
View GitHub Profile
@sskylar
sskylar / tagged_posts.html
Created March 4, 2015 00:08
Get posts for a specific tag from multiple pages
{% for post in site.posts %}
{% if post.taxonomy['tags'].all contains 'Featured' %}
<li><a href="{{post.url}}">{{post.title}}</a></li>
{% endif %}
{% endfor %}
@sskylar
sskylar / classy_body.html
Created February 28, 2015 22:44
Apply classes to inline body images using asset metadata in Siteleaf
{% comment %} Start with the default body {% endcomment %}
{% assign classy_body = body %}
{% comment %} Loop through assets and append asset's meta['class'] to img tags {% endcomment %}
{% for asset in assets %}
{% if asset.meta['class'] %}
{% capture img_src %}src="{{asset.url}}"{% endcapture %}
{% capture img_classy %}{{img_src}} class="{{asset.meta['class']}}"{% endcapture %}
{% assign classy_body = classy_body | replace: img_src, img_classy %}
{% endif %}
@sskylar
sskylar / config.ru
Created February 27, 2015 20:21
Siteleaf config using ENV variables
# Intended for development purposes only, do not upload or use in production.
# See https://github.com/siteleaf/siteleaf-gem for documentation.
require 'rubygems'
require 'siteleaf'
Siteleaf.api_key = ENV['API_KEY']
Siteleaf.api_secret = ENV['API_SECRET']
run Siteleaf::Server.new(:site_id => ENV['SITE_ID'])
@sskylar
sskylar / iam_single_bucket.json
Last active July 30, 2020 16:00
Siteleaf IAM policy for single bucket (most restrictive)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowHostingDropdown",
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
@sskylar
sskylar / sidebar_nav.html
Last active July 10, 2018 21:17
Sidebar nav for pages/subpages in Siteleaf v1
{% comment %} 1. Extract 'section' from '/section/page/subpage' {% endcomment %}
{% assign section = url | remove_first:'/' | split:'/' | first %}
{% comment %} 2. Loop through pages in this section {% endcomment %}
<ul>
{% for page in site.pages[section].pages %}
<li>
<a href="{{page.url}}"{% if page.url == curent.url %}class="selected"{% endif %}>{{page.title}}</a>
{% comment %} 3. Expand subnav for current page or any subpage {% endcomment %}
{% if current.url contains page.url and page.pages.size > 0 %}
@sskylar
sskylar / has_tag.html
Created February 4, 2015 16:43
Check if post contains a particular tag in Siteleaf
{% if taxonomy['tags'].all contains 'My Tag' %}true{% endif %}
@sskylar
sskylar / authors.html
Created January 31, 2015 20:47
Group posts by author in Siteleaf
{% assign authors = site.posts.all | map:'author' | sort:'name' %}
{% assign author_id = nil %}
{% for author in authors %}
{% unless author_id == author.id %}
{% assign author_id = author.id %}
<h2><img src="{{author.avatar}}" width="20"> {{ author.name }}</h2>
<ul>
{% for post in site.posts %}
{% if post.author.id == author_id %}
@sskylar
sskylar / _related_posts.html
Created January 29, 2015 17:59
Get related posts based on current page's slug
@sskylar
sskylar / _header.html
Created January 29, 2015 16:55
Redirect to parent page
{% if type == 'post' %}<meta http-equiv="refresh" content="0;url=../">{% endif %}
@sskylar
sskylar / default.html
Created January 29, 2015 16:54
Redirect to parent page
<!doctype html>
<html>
<head>
<meta http-equiv="refresh" content="0;url=../">
</head>
<body>
</body>
</html>