Skip to content

Instantly share code, notes, and snippets.

View cbratschi's full-sized avatar

Christoph Bratschi cbratschi

View GitHub Profile
@cbratschi
cbratschi / live-preview.tsx
Created August 19, 2024 14:21
Payload 2.x Live Preview with Next.js
Parts:
- server component: see page.tsx
- client component: LivePreview
Difference to Payload 3.x:
- updates immediately, does not have to wait for draft to be saved
@cbratschi
cbratschi / image-blurhash-css.ts
Created August 23, 2023 14:50
Blurhash to CSS (TypeScript example)
import { decode } from 'blurhash';
import { CSSProperties } from 'react';
/**
* Get a pixel value.
*
* @param pixelBytes
* @param x
* @param y
* @param width