Gatsby-theme-novela: Bad author page slug

Created on 25 Aug 2019  路  7Comments  路  Source: narative/gatsby-theme-novela

https://github.com/narative/gatsby-theme-novela/blob/master/%40narative/gatsby-theme-novela/gatsby/node/createPages.js#L29

This slugify function is a bit too simple:

function slugify(str, base) {
  const slug = str
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, "-")
    .replace(/(^-|-$)+/g, "");

  return `${base}/${slug}`.replace(/\/\/+/g, "/");
}

This lead to "/authors/s-bastien-lorber" for my author page

I suggest using a technique to replace accents with non-accent chars before replacing by -. Also using a dedicated slugification package could do the job
https://stackoverflow.com/a/37511463/82609

Eventually having the ability to choose my own slug could be handy

Most helpful comment

Thanks :)

All 7 comments

Will add a package to handle this and have it the same as articles where you can define an optional slug that overrides the generated one.

Special characters and custom slug now supported for authors.
v0.4.2

Thanks :)

Same issue for posts title m茅tro becomes m-tro - could we get the same fix there?

great idea. will port it to handle Posts as well.

This should already be handled actually! at least locally. maybe I need to publish the update :)

Screen Shot 2019-08-30 at 10 02 26 AM

That's probably going to help 馃槢

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mwood23 picture mwood23  路  4Comments

alfieqashwa picture alfieqashwa  路  4Comments

jorgeorejas picture jorgeorejas  路  3Comments

vzahradnik picture vzahradnik  路  3Comments

dgovil picture dgovil  路  3Comments