export function contentTypeBuilder(existingFields = []) {
    return {
        slug: '',
        fields: existingFields.length ? existingFields : [],

        updateSlug(name) {
            this.slug = name
                .toLowerCase()
                .replace(/[^a-z0-9\s-]/g, '')
                .replace(/\s+/g, '-')
                .replace(/-+/g, '-')
        },

        addField() {
            this.fields.push({ key: '', label: '', type: 'text' })
        },
    }
}
