feat(SPA): screens for Sites and Authors

This commit is contained in:
Florian Sylvain committed 2026-10-14 23:00:50 +02:00
1 parent b34a173d83
commit 3d81d2c717
82 files changed
+10676 -37

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
import { t } from '@/i18n'
import { copy } from '@/lib/directoryCopy'
import {
SITE_KEY_MAX,
SITE_KEY_MIN,
SLUG_PATTERN,
characterCount,
isSecureUrl,
siteUrlMessage,
siteUrlProblem,
} from '@/lib/directory'
export const BIO_MAX = 280
export function nameProblem(name: string) {
return name.trim() ? '' : copy('enterName')
}
export function bioProblem(bio: string) {
return characterCount(bio) > BIO_MAX ? copy('shortenBio') : ''
}
export function secureUrlProblem(value: string) {
return isSecureUrl(value) ? '' : copy('urlHttps')
}
export function optionalSecureUrlProblem(value: string) {
return value.trim() ? secureUrlProblem(value) : ''
}
export function authorSlugProblem(slug: string) {
if (!slug || SLUG_PATTERN.test(slug)) {
return ''
}
return t('Lowercase letters, numbers and hyphens. Unique across all authors.')
}
export function siteKeyProblem(key: string) {
const valid = SLUG_PATTERN.test(key) && key.length >= SITE_KEY_MIN && key.length <= SITE_KEY_MAX
return valid ? '' : t('Use lowercase letters, numbers and hyphens, 2 to 32 characters.')
}
export function baseUrlProblem(value: string) {
const problem = siteUrlProblem(value)
return problem ? siteUrlMessage(problem) : ''
}