decaporg / decaporg/decap-cms

Replace single quote with sanitize_replacement character in slugs

Open
#7,147 0 comments 0 reactions 0 assignees View on GitHub
area: slugs type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Is your feature request related to a problem? Please describe.**

Current slug feature removes single quotes (used as apostrophes) without replacing them with the `sanitize_replacement` character.

For example I have a French content titled `Test d'image`.

The slug is computed as `test-dimage` with this configuration:

```yaml
slug:
encoding: "ascii"
clean_accents: true
sanitize_replacement: "-"
```

This is wrong, as “dimage” is not a word.

I believe the slug should be `test-d-image`.

**Describe the solution you'd like**

I think single quotes (and maybe other characters) should also be replaced with the `sanitize_replacement` character.

**Describe alternatives you've considered**

I could use my own slugify function, if it was possible.

Maybe this PR would allow it (I'm not sure):
- #6690

In other projects, I use [@sindresorhus/slugify](https://github.com/sindresorhus/slugify).

I even developed an extended version for some non latin characters, this is not a trivial topic: https://github.com/nhoizey/eleventy-plugin-pack11ty/blob/main/_11ty/utils/slugify.js

Contributor guide

Open the contributing guide

Research direction

Start by locating the slug generation entry point and the handling of the sanitize_replacement configuration, then reproduce the provided French title and ASCII slug settings. Done means single quotes are replaced consistently with the configured character so the example produces `test-d-image`, with coverage for the behavior and any related characters considered in scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
content
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.