This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="sv"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<script src="https://cdn.tailwindcss.com"></script> | |
<script> | |
tailwind.config = { | |
theme: { | |
extend: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sanityClient from 'part:@sanity/base/client'; | |
// Slugify function from https://gist.github.com/mathewbyrne/1280286 for fixing some weird letters etc | |
function slugify(str) { | |
str = str.replace(/^\s+|\s+$/g, ''); // trim leading/trailing white space | |
str = str.toLowerCase(); // convert string to lowercase | |
str = str.replace(/[^a-z0-9 -]/g, '') // remove any non-alphanumeric characters | |
.replace(/\s+/g, '-') // replace spaces with hyphens | |
.replace(/-+/g, '-'); // remove consecutive hyphens | |
return str; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to handle click events | |
// jQuery | |
$('.button').on('click', function() { /* handle click event */}); | |
// Vanilla | |
// On one button | |
document.querySelector('.button').addEventListener('click', (e) => { /* handle click event */}); | |
// On multiple buttons | |
document.querySelectorAll('.button').forEach((button) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get elements | |
// jQuery | |
var myDivs = $('.my-div'); // Get all divs | |
const myDiv = document.querySelector('.myDiv'); // Get first div | |
const myDivs = document.querySelectorAll('.myDiv'); // Get all divs// How to handle click events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add custom post types main RSS feed. | |
function wp_rss_feed( $query ) { | |
if ( $query->is_feed() ) | |
$query->set( 'post_type', array( 'post', 'events', 'books' ) ); | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'wp_rss_feed' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); |