Skip to content

Instantly share code, notes, and snippets.

View cbratschi's full-sized avatar

Christoph Bratschi cbratschi

View GitHub Profile
@cbratschi
cbratschi / README.md
Created October 21, 2026 16:39
Payload 3.91.0 MongoDB: conflicting indexes on separate globals (standalone reproduction)

Payload MongoDB global index-name conflict

Standalone reproduction with stock Payload 3.91.0, its MongoDB adapter 3.91.0, and Mongoose 8.24.1. No application plugins or Next.js server are needed.

Use Node.js 26 and an existing local MongoDB replica set. The tested server is MongoDB 8.0.28. Save all three files in one directory, then run:

npm install
@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