Updated the slugify function to match the latest Craft createSlug function