Skip to content

Instantly share code, notes, and snippets.

View rexxars's full-sized avatar

Espen Hovlandsdal rexxars

View GitHub Profile
@rexxars
rexxars / bundleChecker.js
Last active March 16, 2021 21:06
Sanity studio bundle update checker
import {useEffect} from 'react'
import config from 'config:sanity'
const BUNDLE_CHECK_INTERVAL = 15 * 1000
async function getCurrentHash() {
const basePath = (config.project && config.project.basePath) || '/'
const html = await fetch(basePath).then((res) => res.text())
const [, hash] = html.match(/app\.bundle\.js\?(\w+)/) || []
return hash
@rexxars
rexxars / groqHookToSlack.groq
Last active August 23, 2022 20:41
GROQ-hook projection example for Slack Block Kit
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": coalesce(title, "Untitled article"),
"emoji": true
}
},
@rexxars
rexxars / sanity-v5-codeshift.js
Created January 12, 2023 21:32
JSCodeShift for Sanity client v5 (default import => named import)
const importName = 'createClient'
v5ClientImport.parser = 'tsx'
module.exports = v5ClientImport
function v5ClientImport(fileInfo, api) {
const j = api.jscodeshift
const root = j(fileInfo.source)
// Imports