Skip to content

fix: correct slugifyTitle hook example in documentation (#16306)#1

Merged
Giorgiosaud merged 1 commit intoBePartnerLabs:mainfrom
payloadcms:main
Apr 20, 2026
Merged

fix: correct slugifyTitle hook example in documentation (#16306)#1
Giorgiosaud merged 1 commit intoBePartnerLabs:mainfrom
payloadcms:main

Conversation

@Giorgiosaud
Copy link
Copy Markdown

What?

Fixed incorrect return statement in the slugifyTitle field hook example in the official documentation.

The example was generating a properly formatted slug but then incorrectly returning the original value instead of the slugified result.

Why?

This was a bug in the documentation that could mislead developers implementing automatic slug generation. The hook appeared to work, but in reality did nothing useful.

How?

  • Changed return value to return slug in the example

Before/After

Before:

const slug = value.toLowerCase()... 
return value // ← bug

**Aftere:**
```ts
const slug = value.toLowerCase()... 
return slug

<!--

Thank you for the PR! Please go through the checklist below and make sure you've completed all the steps.

Please review the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository if you haven't already.

The following items will ensure that your PR is handled as smoothly as possible:

- PR Title must follow conventional commits format. For example, `feat: my new feature`, `fix(plugin-seo): my fix`.
- Minimal description explained as if explained to someone not immediately familiar with the code.
- Provide before/after screenshots or code diffs if applicable.
- Link any related issues/discussions from GitHub or Discord.
- Add review comments if necessary to explain to the reviewer the logic behind a change

### What?

### Why?

### How?

Fixes #

-->

## What?

Fixed incorrect return statement in the `slugifyTitle` field hook
example in the official documentation.

The example was generating a properly formatted slug but then
incorrectly returning the original `value` instead of the slugified
result.

## Why?

This was a bug in the documentation that could mislead developers
implementing automatic slug generation. The hook appeared to work, but
in reality did nothing useful.

## How?

- Changed `return value` to `return slug` in the example

## Before/After

**Before:**
```ts
const slug = value.toLowerCase()... 
return value // ← bug

**Aftere:**
```ts
const slug = value.toLowerCase()... 
return slug
@Giorgiosaud Giorgiosaud merged commit da48a80 into BePartnerLabs:main Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants