瀏覽代碼

website: Add anchor link for each header.

This fixes #1426.
Qi Xiao 2 年之前
父節點
當前提交
50b0db0a59

文件差異過大導致無法顯示
+ 1 - 5
website/icon-font.css


+ 2 - 2
website/index.toml

@@ -2,12 +2,12 @@ title = "Elvish Shell"
 author = "Qi Xiao"
 feedPosts = 10
 template = "template.html"
-baseCSS = ["reset.css", "style.css"]
+baseCSS = ["reset.css", "style.css", "icon-font.css"]
 rootURL = "https://elv.sh"
 
 [index]
 name = "home"
-extraCSS = ["icon-font.css", "home.css"]
+extraCSS = ["home.css"]
 extraJS = ["home.js"]
 
 [[categories]]

+ 10 - 2
website/style.css

@@ -402,6 +402,16 @@ pre.ttyshot, pre.ttyshot code {
     background-color: gray;
 }
 
+/** Header anchors. */
+.anchor {
+    opacity: 0;
+    font-size: 90%;
+}
+
+*:hover > .anchor {
+    opacity: 1;
+}
+
 /**
  * Dark theme.
  */
@@ -467,5 +477,3 @@ td, th {
 .dark td, .dark th {
     border-color: #444;
 }
-
-

+ 1 - 1
website/tools/md-to-html

@@ -18,4 +18,4 @@ mydir=$(dirname "$0")
 
 $mydir/macros.bin -repo $mydir/../.. -elvdoc $mydir/elvdoc.bin < $1 |
   $mydir/highlight.bin |
-  pandoc -f gfm+smart+attributes --data-dir=$mydir/pandoc-data --metadata title=${1%.md} -o $2 $opts
+  pandoc -f gfm+smart+attributes --data-dir=$mydir/pandoc --lua-filter=$mydir/pandoc/header-anchors.lua --metadata title=${1%.md} -o $2 $opts

+ 6 - 0
website/tools/pandoc/header-anchors.lua

@@ -0,0 +1,6 @@
+function Header(el)
+  local link = pandoc.Link('', '#'..el.identifier, '',
+                           {['class'] = 'anchor icon-link', ['aria-hidden'] = 'true'})
+  el.content:insert(link)
+  return el
+end

+ 0 - 0
website/tools/pandoc-data/templates/toc-and-body.html → website/tools/pandoc/templates/toc-and-body.html


部分文件因文件數量過多而無法顯示