Skip to content

Instantly share code, notes, and snippets.

View iksent's full-sized avatar

Ilya Iksent iksent

View GitHub Profile
@iksent
iksent / SEO.tsx
Last active March 25, 2022 09:52
Simplified React Component for SEO
import React from 'react'
import Head from 'next/head' // or react-helmet
const SEO = () => {
// Fill this object with your data (from i18n / props / hooks / etc.)
const seo = {
name: 'Project Name',
title: 'Page title',
description: 'Page description',
image: 'path/to/page-social-image',
@iksent
iksent / number-formatters.ts
Last active June 3, 2022 09:39
Number Formatters
export const toFixedN = (
number: number | null | undefined,
fractionDigits = 8,
canBeNull = true,
): string => {
let num = number
// @ts-ignore
num = +num
if (isNaN(num)) {
@iksent
iksent / gatsby-node-es6.js
Last active February 10, 2021 09:31
Gatsby + Strapi: Solving "dummy-content" problem for "Dynamic Zones"
const path = require('path')
const fs = require('fs')
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace)
}
export const createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions
@iksent
iksent / Confirm.php
Created August 13, 2020 11:10
Directus Public User Registration (+ Email Confirmation!)
<?php
require_once __DIR__ . '/SignupConfig.php';
use Directus\Application\Application;
use Directus\Application\Http\Request;
use Directus\Application\Http\Response;
use Directus\Authentication\Exception\ExpiredRequestTokenException;
use Directus\Authentication\Exception\InvalidTokenException;
use Directus\Util\JWTUtils;
@iksent
iksent / scrolling.js
Last active May 31, 2020 06:49
[ReactJS hook] Detect Scrolls To Bottom
import { useScrollPosition } from '@n8tb1t/use-scroll-position'
import { useRef } from 'react'
import { get } from 'lodash'
export const useOnEndScroll = (onEnd: () => void, disabled: boolean = false) => {
const { body, documentElement } = document
const isTracking = useRef<boolean>(true) // To avoid repeated requests
const offsetFromBottom = 100
useScrollPosition(
@iksent
iksent / AdminMenusImprover.php
Created September 10, 2019 06:24
Add new fields to nav_menu_item posts in the WordPress menu editor.
<?php
require_once plugin_dir_path( __FILE__ ) . '/CustomWalkerNavMenuEdit.php';
class AdminMenusImprover {
/**
* Class instance.
*
* @var AdminTaxonomiesImprover instance
*/