Commit 72ac8a9

HPCesia <me@hpcesia.com>
2025-03-15 03:20:49
fix: hash scroll offset
1 parent 91c410f
Changed files (2)
src/layouts/GlobalLayout.astro
@@ -122,7 +122,9 @@ const favicons: Favicon[] =
         delay: 2000,
       }),
       new SwupScriptsPlugin(),
-      new SwupScrollPlugin(),
+      new SwupScrollPlugin({
+        offset: () => (document.querySelector('#navbar') as HTMLDivElement).offsetHeight,
+      }),
     ],
   });
 
src/styles/markdown.css
@@ -11,7 +11,6 @@ article {
     display: inline-block;
     width: 100%;
     margin: 1rem 0 0.5rem;
-    scroll-margin-top: 4rem;
     font-weight: bold;
     position: relative;
 
@@ -59,11 +58,6 @@ article {
 
   a:not(.card) {
     @apply text-primary underline decoration-dashed;
-
-    &[data-footnote-ref],
-    &[data-footnote-backref] {
-      scroll-margin-top: 4rem;
-    }
   }
 
   /* 媒体元素 */