Foundation + Schemas
This commit is contained in:
5
src/lib/constants/collections.ts
Normal file
5
src/lib/constants/collections.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/* === CONTENT COLLECTIONS === */
|
||||
|
||||
export const ARTICLES = 'articles'
|
||||
export const PAGES = 'pages'
|
||||
export const TAGS = 'tags'
|
||||
20
src/lib/constants/status.ts
Normal file
20
src/lib/constants/status.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export const STATUS_OPTIONS = [
|
||||
{
|
||||
label: 'Draft',
|
||||
value: 'draft',
|
||||
},
|
||||
{
|
||||
label: 'Published',
|
||||
value: 'published',
|
||||
},
|
||||
{
|
||||
label: 'Unlisted',
|
||||
value: 'unlisted',
|
||||
},
|
||||
{
|
||||
label: 'Archived',
|
||||
value: 'archived',
|
||||
},
|
||||
] as const
|
||||
|
||||
export type Status = (typeof STATUS_OPTIONS)[number]['value']
|
||||
6
src/lib/content/assets.ts
Normal file
6
src/lib/content/assets.ts
Normal 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
34
src/lib/content/slug.ts
Normal 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, '')
|
||||
}
|
||||
Reference in New Issue
Block a user