Jacky Zhao
2024-01-13 6babb788edbdeaf532d406d6daa4d046e5223c7b
fix: sluggify pound (closes #681)
2 files modified
6 ■■■■ changed files
quartz/util/path.test.ts 2 ●●●●● patch | view | raw | blame | history
quartz/util/path.ts 4 ●●● patch | view | raw | blame | history
quartz/util/path.test.ts
@@ -105,6 +105,8 @@
        ["index.md", "index"],
        ["test.mp4", "test.mp4"],
        ["note with spaces.md", "note-with-spaces"],
        ["test/special chars?.md", "test/special-chars-q"],
        ["test/special chars #3.md", "test/special-chars-3"],
      ],
      path.slugifyFilePath,
      path.isFilePath,
quartz/util/path.ts
@@ -50,7 +50,9 @@
function sluggify(s: string): string {
  return s
    .split("/")
    .map((segment) => segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q")) // slugify all segments
    .map((segment) =>
      segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q").replace(/#/g, ""),
    ) // slugify all segments
    .join("/") // always use / as sep
    .replace(/\/$/, "")
}