Skip to content

Instantly share code, notes, and snippets.

View jeremycaldwell's full-sized avatar
💭
Currently available for hire.

Jeremy Caldwell jeremycaldwell

💭
Currently available for hire.
View GitHub Profile
/**
* Implements hook_preprocess_HOOK() for page title templates.
*/
function THEMENAME_preprocess_page(&$variables) {
$node = \Drupal::request()->attributes->get('node');
if (isset($node) && $node instanceof Node) {
// Check node types and remove the block title.
switch ($node->getType()) {
case "bio":
case "form":
@jeremycaldwell
jeremycaldwell / input.scss
Last active June 29, 2021 22:02
Generated by SassMeister.com.
$base-font-size: 16px; // The font size set on the root html element.
@function rem($size) {
$remSize: $size / $base-font-size;
@return #{$remSize}rem;
}
//////// CODE STARTS BELOW ////////
p {
@jeremycaldwell
jeremycaldwell / web|_data|basicpages.js
Last active September 18, 2020 20:31
Sanity.io components in 11ty
const groq = require('groq')
const BlocksToMarkdown = require('@sanity/block-content-to-markdown')
const client = require('../utils/sanityClient.js')
const serializers = require('../utils/serializers')
const overlayDrafts = require('../utils/overlayDrafts')
const hasToken = !!client.config().token
function generateBasicpage (basicpage) {
return {
...basicpage,
@jeremycaldwell
jeremycaldwell / menu.scss
Created November 30, 2016 23:02
Center aligned menu with borders
// "About Us" menu.
.menu-about-us {
@include clearfix;
text-align: center;
// Block title.
h2.block__title {
@include font-size(18);
margin-bottom: rem(10px);
}
@jeremycaldwell
jeremycaldwell / SassMeister-input.scss
Last active January 3, 2018 17:32
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
// Mixins.
@mixin icon {
background-position: 0 0;
background-repeat: no-repeat;
background-size: contain;
@jeremycaldwell
jeremycaldwell / all-values-array.php
Created November 15, 2016 16:13
Print all values from array
$teaser_images = '';
$teaser_images = field_get_items('node', $node, 'field_teaser_image');
if (!empty($teaser_images)) {
foreach ($teaser_images as $teaser_image) {
$path = $teaser_image['uri'];
$alt = $teaser_image['alt'];
$title = $teaser_image['title'];
$nodeURL = 'node/' . $node->nid;
$image = theme_image_style(
array(
@jeremycaldwell
jeremycaldwell / themename.php
Created October 11, 2016 18:59
Add custom class to body based on field value.
function THEMENAME_preprocess_html(&$variables) {
// Get the value of the field and add it as a class on <body>.
$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
if ($node->field_layout) {
$layout_style = $node->field_layout->value;
$vars['attributes']['class'][] = 'layout-' . str_replace('_', '-', $layout_style);
} else {
$variables['attributes']['class'][] = 'layout-CUSTOM-CLASS';
}
@jeremycaldwell
jeremycaldwell / bower.json
Last active January 3, 2018 17:33
Gulp and Libsass starter. 1. npm install 2. bower install
{
"name": "Linux Foundation Bower Dependencies",
"version": "0.0.1",
"authors": [
"Jeremy Caldwell <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
@jeremycaldwell
jeremycaldwell / smoothscroll.js
Last active January 3, 2018 17:33
Smooth scroll
// Smooth scroll.
Drupal.behaviors.smoothScroll = {
attach: function(context, settings) {
$('.scroll').click(function(event) {
event.preventDefault();
$('html,body').animate({
scrollTop: $(this.hash).offset().top
}, 500);
});
}
@jeremycaldwell
jeremycaldwell / SassMeister-input.scss
Created February 12, 2016 18:45
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
// color() mixin:
/////////////////////////////////////////////////////
// Gets the specified color from the color palette //
// //
// Usage: //
// background: color('blue'); // #0099CE //