Skip to content

Instantly share code, notes, and snippets.

View tomblanchard's full-sized avatar

Tom Blanchard tomblanchard

View GitHub Profile
@tomblanchard
tomblanchard / product.temporary.liquid
Created May 29, 2020 09:10
/templates/product.temporary.liquid
{% layout 'redirect' %}
{
"namespace" : "seo",
"key" : "hidden",
"value" : 1,
"value_type" : "integer"
}
@tomblanchard
tomblanchard / redirect.liquid
Created May 29, 2020 08:59
/layout/redirect.liquid
<!DOCTYPE html>
<html class="template-{{ template | handle }}" lang="{{ shop.locale }}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="robots" content="noindex, nofollow" />
<meta http-equiv="refresh" content="0; url=/" />
{{ content_for_header }}
</head>
{% assign google_analytics_id = nil %}
{% if content_for_header contains "ga('create', '" %}
{% assign google_analytics_id = content_for_header | split: "ga('create', '" | last | split: "'" | first | strip %}
{% endif %}
{% if google_analytics_id %}
<p>My Google Analytics ID is: {{ google_analytics_id }}</p>
{% endif %}
var express = require('express');
var cors = require('cors');
var Shopify = require('shopify-api-node');
var app = express();
var port = 3000;
// Shopify API
var shopify = new Shopify({
shopName: 'liquify-scripts',
var element = document.querySelector('[data-module-language-selector]');
if (element) {
element.addEventListener('change', (event) => {
window.location = event.target.value;
});
}
@tomblanchard
tomblanchard / mini-modernizr.html
Created April 25, 2014 14:09
Mini Modernizr: I only ever use Modernizr mostly to check for JS and / or touch screen devices. This tiny piece of code will replace the classes which are on the `<html>` element `no-js` with `js` and `no-touch` with `touch`.
<script>!function(a,b){"use strict";b.documentElement.className=b.documentElement.className.replace("no-js","js"),("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)&&(document.documentElement.className=document.documentElement.className.replace("no-touch","touch"))}(window,document);</script>
@tomblanchard
tomblanchard / bigcartel-feed.js
Last active March 6, 2018 12:29
BigCartel Feed.
$.getJSON('http://api.bigcartel.com/USERNAME/products.json?limit=5&callback=?', function(data) {
$.each(data, function(i, obj) {
$('\
<a href="http://USERNAME.bigcartel.com' + obj.url + '">' +
obj.name +
'$' + parseFloat(obj.price, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,').toString() +
'<img width="100" src="' + obj.images[0].url + '" alt="">' +
'</a>'
).appendTo('.products');
@tomblanchard
tomblanchard / shopify-encapsulated-components.md
Last active April 24, 2017 04:27
Shopify: Encapsulated components.

Concept

In React (JSX), you create a component like so:

function Button(props) {
  return (
    <button className={"button " + (props.color ? props.color : '')} type="button">
      {props.value}
    </button>