Coder Social home page Coder Social logo

Comments (8)

oscarotero avatar oscarotero commented on August 17, 2024 1

I just added options to configure the slugifyUrls. To keep the ä character, use the replace option:

const site = lume({
  slugifyUrls: {
    replace: {
        "ä": "ä"
    }
  },
});

If you want to keep all non-alphanumeric characters:

const site = lume({
  slugifyUrls: {
    alphanumeric: false
  },
});

from lume.

valtlai avatar valtlai commented on August 17, 2024

You can disable that by setting slugifyUrls: false in your Lume config:

const site = lume({
  slugifyUrls: false,
});

from lume.

enjikaka avatar enjikaka commented on August 17, 2024

But then I lose the actual slugify logic?

from lume.

enjikaka avatar enjikaka commented on August 17, 2024

lume/utils.js

Lines 97 to 102 in 22717d5

export function slugify(string) {
return string.toLowerCase()
.normalize("NFKD")
.replaceAll(/[\s_-]+/g, "-")
.replaceAll(/[^\w\/-]/g, (char) => slugChars.get(char) || "");
}

Can a config key to disable just the L101 step be made?

from lume.

oscarotero avatar oscarotero commented on August 17, 2024

@valtlai Maybe the regex could ignore all characters defined in slugChars map, so users can enable any character with:

import { slugChars } from "https://deno.land/x/[email protected]/utils.js";

slugChars.set("ä", "ä");

from lume.

valtlai avatar valtlai commented on August 17, 2024

Yeah, that’s one possibility.

And/or maybe the slugifyUrls option could take an object of options to configure the slugifier: slugifyUrls: { nonAscii: true } (maybe there’s a better name?) would preserve non-ASCII letters (and maybe numbers too) in slugs as it.

Or maybe it could take a string: "ascii" (the current default), "unicode" (to preserve non-ASCII letters, and maybe numbers, too) or "off" (to disable the slugifier).

from lume.

oscarotero avatar oscarotero commented on August 17, 2024

I like the idea of an object with options. For example:

  • separator (By default -)
  • lowercase (By default true)
  • replacements (The object/map with the characters to replace)
  • onlyAlfanumeric (By default true)
  • onlyFilenames (slugify only the last part of the url, not the directories)

from lume.

enjikaka avatar enjikaka commented on August 17, 2024

That should cover my case at least it seems. Thanks. :)

from lume.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.