Skip to content

Instantly share code, notes, and snippets.

@lukebussey
lukebussey / hubspot_pagination.html
Created May 9, 2017 15:27
HubSpot Pagination Template
{% set total_pages = contents.total_page_count %} <!-- sets variable for total pages -->
{% set more_pages = total_pages - current_page_num %} <!-- sets variable for how many more pages are past the current pages -->
{% if total_pages > 1 %}
<nav>
<ul class="pagination">
{% if current_page_num != 1 %}
<li><a href="{% if last_page_num=="1" %}{{ group.absolute_url }}{% else %}{{blog_page_link(last_page_num)}}{% endif %}"><i class="fa fa-angle-double-left"></i></a></li>
{% endif %}
{% if more_pages == 0 %}
{% if current_page_num - 4 == 1 %}<li><a href="{{ group.absolute_url }}">{{ current_page_num - 4 }}</a></li>{% endif %}
@lukebussey
lukebussey / hubspot_schema.html
Last active May 20, 2021 20:36
HubSpot Blog Schema.org Markup
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"@id": "#organization",
"name": "Outlyer",
"url": "https://www.outlyer.com/",
"sameAs": [
"https://github.com/outlyerapp",
"https://twitter.com/outlyer",
npm list -g --depth=0
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt -reqexts SAN -extensions SAN \
-config <(cat /System/Library/OpenSSL/openssl.cnf \
<(printf '[SAN]\nsubjectAltName=DNS:*.local'))
sub vcl_recv {
if (req.http.host == "domain.com" && req.url.path == "/user") {
error 601 "user";
}
}
sub vcl_error {
if (obj.status == 601) {
set obj.http.Content-Type = "text/json";
set obj.status = 200;
@lukebussey
lukebussey / functions.php
Created February 21, 2020 23:35
Add Custom Font Formats to Divi 4
/* Mime Types Support */
add_filter('upload_mimes', 'custom_mime_types', 999999);
function custom_mime_types($mimes) {
$mimes['otf'] = 'application/x-font-opentype';
$mimes['woff'] = 'application/font-woff';
$mimes['woff2'] = 'application/font-woff2';
return $mimes;
}
/* Custom Font Types Support */
const Sitemapper = require('sitemapper');
(async () => {
const mapper = new Sitemapper();
const sitemap = await mapper.fetch(`https://www.example.com/sitemap.xml`);
console.log(sitemap);
})();
var cookieVal = document.cookie,
testVal = "mixpanel",
localStorageKey = "mixpanel-cookie",
canWriteCookie = false;
// Test cookie
document.cookie = testVal;
canWriteCookies = document.cookie === testVal;
// Restore cookie
import PropTypes from 'prop-types';
import { useState, useEffect, useContext, createContext } from 'react';
import { useRouter } from 'next/router';
import merge from 'deepmerge';
import usePrevious from 'hooks/usePrevious';
const useProvideSegment = () => {
const [location, setLocation] = useState();
const router = useRouter();

To embed the contents of an SVG file into your site using NextJS 12 with the new Rust-based compiler, perform the following steps:

  1. Install @svg/webpack:
$ npm install --save-dev @svgr/webpack
  1. Create a svgr.config.js config file with the following contents. This will remove the width and height from the SVG but keep the viewBox for correct scaling.