sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
15 lines (10 loc) • 346 B
text/typescript
import {camelCase} from 'lodash'
import getSlug from 'speakingurl'
import {disallowedPattern} from './validateId'
export function getStructureNodeId(title: string, id?: string): string {
if (id) {
return id
}
const camelCased = camelCase(title)
return disallowedPattern.test(camelCased) ? camelCase(getSlug(title)) : camelCased
}