From 1406ee0f05dc688e1b7635d3ce14e63d1c42a973 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 04 Jun 2023 17:37:43 +0000
Subject: [PATCH] update spinners

---
 quartz/plugins/transformers/ofm.ts |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts
index c089e02..1dad0b4 100644
--- a/quartz/plugins/transformers/ofm.ts
+++ b/quartz/plugins/transformers/ofm.ts
@@ -12,7 +12,7 @@
 
 const defaultOptions: Options = {
   highlight: true,
-  wikilinks: true
+  wikilinks: true,
 }
 
 export class ObsidianFlavoredMarkdown extends QuartzTransformerPlugin {
@@ -38,17 +38,21 @@
         const backlinkRegex = new RegExp(/!?\[\[([^\[\]\|\#]+)(#[^\[\]\|\#]+)?(\|[^\[\]\|\#]+)?\]\]/, "g")
         return (tree: Root, _file) => {
           findAndReplace(tree, backlinkRegex, (value: string, ...capture: string[]) => {
-            const [path, rawHeader, rawAlias] = capture
-            const header = rawHeader?.slice(1).trim() ?? ""
-            const alias = rawAlias?.slice(1).trim() ?? value 
-            const url = slugify(path.trim() + header)
-            return {
-              type: 'link',
-              url,
-              children: [{
-                type: 'text',
-                value: alias
-              }]
+            if (value.startsWith("!")) {
+              // TODO: handle embeds
+            } else {
+              const [path, rawHeader, rawAlias] = capture
+              const anchor = rawHeader?.trim() ?? ""
+              const alias = rawAlias?.slice(1).trim() ?? path
+              const url = slugify(path.trim() + anchor)
+              return {
+                type: 'link',
+                url,
+                children: [{
+                  type: 'text',
+                  value: alias
+                }]
+              }
             }
           })
         }

--
Gitblit v1.10.0