From fcd81353f88b613e5e93c089e10e530d08695b3f Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 01 Jun 2023 23:48:38 +0000
Subject: [PATCH] heading linking
---
quartz/path.ts | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/quartz/path.ts b/quartz/path.ts
index 4127fc0..4f3bfa7 100644
--- a/quartz/path.ts
+++ b/quartz/path.ts
@@ -1,4 +1,7 @@
import path from 'path'
+import SlugAnchor from 'github-slugger'
+
+const slugAnchor = new SlugAnchor()
function slugSegment(s: string): string {
return s.replace(/\s/g, '-')
@@ -6,7 +9,7 @@
export function slugify(s: string): string {
const [fp, anchor] = s.split("#", 2)
- const sluggedAnchor = anchor === undefined ? "" : "#" + slugSegment(anchor)
+ const sluggedAnchor = anchor === undefined ? "" : "#" + slugAnchor.slug(anchor)
const withoutFileExt = fp.replace(new RegExp(path.extname(fp) + '$'), '')
const rawSlugSegments = withoutFileExt.split(path.sep)
const slugParts: string = rawSlugSegments
--
Gitblit v1.10.0