Foundation + Schemas

This commit is contained in:
2026-09-21 16:59:08 +02:00
parent 3a27b60be4
commit f82d631ba6
25 changed files with 391 additions and 78 deletions

View File

@@ -0,0 +1,6 @@
export const ASSET_ROOT = 'src/assets/content'
export const assets = (collection: string) => ({
directory: `${ASSET_ROOT}/${collection}`,
publicPath: `/${ASSET_ROOT}/${collection}/`,
})

34
src/lib/content/slug.ts Normal file
View File

@@ -0,0 +1,34 @@
export const SEGMENT = /^[a-z0-9][a-z0-9_-]*$/
export const OPTIONAL_SEGMENT = /^([a-z0-9][a-z0-9_-]*)?$/
export const SEGMENT_MESSAGE = 'Lowercase letters, digits, - and _'
const UMLAUTS: Record<string, string> = {
ä: 'ae',
ö: 'oe',
ü: 'ue',
ß: 'ss',
Ä: 'ae',
Ö: 'oe',
Ü: 'ue',
å: 'aa',
æ: 'ae',
ø: 'oe',
Å: 'aa',
Æ: 'ae',
Ø: 'oe',
}
export const slugify = (text: string): string => {
return text
.split('')
.map((char) => UMLAUTS[char] || char)
.join('')
.normalize('NFKD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9 _-]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.replace(/^[-_]+|[-_]+$/g, '')
}