fix: fixed title parsing for special characters

This commit is contained in:
Leyla Becker 2026-02-22 17:05:57 -06:00
parent 602e92f986
commit 93837aaf20
2 changed files with 70 additions and 38 deletions

View file

@ -44,6 +44,8 @@ const getPlantBased = (filePath) => {
const slugify = (text) => {
return text
.toLowerCase()
.normalize('NFD') // Decompose accented characters
.replace(/[\u0300-\u036f]/g, '') // Remove combining diacritical marks
.replace(/\s+/g, '-') // Replace spaces with hyphens
.replace(/[()]/g, '') // Remove parentheses
.replace(/[^\w-]+/g, '') // Remove non-word chars except hyphens
@ -224,7 +226,7 @@ module.exports = {
return getSlugFromPath(data.page.inputPath);
},
title: (data) => {
if (data.title && data.title !== data.page.fileSlug) {
if (data.title) {
return data.title;
}
const slug = getSlugFromPath(data.page.inputPath);