From 0dc51ff39c9c867dd85c37a01c366cd5f278f032 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Tue, 15 Feb 2022 19:50:34 +0000
Subject: [PATCH] Merge branch 'hugo' of https://github.com/jackyzha0/quartz into hugo

---
 layouts/partials/popover.html |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/layouts/partials/popover.html b/layouts/partials/popover.html
index d9cc941..3a7de11 100644
--- a/layouts/partials/popover.html
+++ b/layouts/partials/popover.html
@@ -1,3 +1,4 @@
+{{if $.Site.Data.config.enableLinkPreview}}
 <script>
   function htmlToElement(html) {
     const template = document.createElement('template')
@@ -6,10 +7,12 @@
     return template.content.firstChild
   }
 
+  const pathRegex = /\.\.?(\/\.\.)*/
   document.addEventListener("DOMContentLoaded", () => {
     [...document.getElementsByClassName("internal-link")]
       .forEach(li => {
-        const linkDest = content[li.dataset.src]
+        console.log(li.dataset.src.replace(pathRegex, ''))
+        const linkDest = content[li.dataset.src.replace(pathRegex, '')]
         if (linkDest) {
           const popoverElement = `<div class="popover">
     <h3>${linkDest.title}</h3>
@@ -26,4 +29,5 @@
         }
       })
   })
-</script>
\ No newline at end of file
+</script>
+{{end}}
\ No newline at end of file

--
Gitblit v1.10.0