Browse Source

fmt: add a pandoc template and add inline nav links

Seven Du 3 năm trước cách đây
mục cha
commit
f012bd6761

+ 1 - 2
Makefile

@@ -38,7 +38,7 @@ $(PDOUTDIR) :
 
 $(PDOUTDIR)/%.html : %.md $(PDOUTDIR)
 	mkdir -p $$(dirname $@)
-	pandoc --toc --css $(CSS) --lua-filter=fmt/pandoc/links.lua -t html -f markdown -s $< -o $@
+	pandoc --toc --css $(CSS) --template fmt/pandoc/template.html --lua-filter=fmt/pandoc/links.lua -t html -f markdown -s $< -o $@
 
 .PHONY : mkdocs
 mkdocs :
@@ -69,4 +69,3 @@ mdbook-clean :
 clean :
 	rm -f docs/SUMMARY.md
 	rm -rf html
-

+ 1 - 1
fmt/pandoc/css/github-pandoc.css

@@ -426,7 +426,7 @@ html,body{        margin: auto;
 
     #TOC {
         position: fixed;
-        top: 0;
+        top: 60px;
         padding: 10px;
         left: 0;
         bottom: 10px;

+ 1 - 1
fmt/pandoc/css/pandoc.css

@@ -333,7 +333,7 @@ body {
 
 #TOC {
   position: fixed;
-  top: 0;
+  top: 60px;
   padding: 10px;
   left: 0;
   bottom: 10px;

+ 1 - 2
fmt/pandoc/css/style.css

@@ -354,7 +354,7 @@ body {
 
 #TOC {
     position: fixed;
-    top: 0;
+    top: 60px;
     padding: 10px;
     left: 0;
     bottom: 10px;
@@ -373,4 +373,3 @@ body {
         overflow-y: auto;
     }
 }
-

+ 132 - 0
fmt/pandoc/template.html

@@ -0,0 +1,132 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
+<head>
+  <meta charset="utf-8" />
+  <meta name="generator" content="pandoc-markdown-css-theme" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
+$for(author-meta)$
+  <meta name="author" content="$author-meta$" />
+$endfor$
+$if(date-meta)$
+  <meta name="dcterms.date" content="$date-meta$" />
+$endif$
+$if(keywords)$
+  <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
+$endif$
+$if(description-meta)$
+  <meta name="description" content="$description-meta$" />
+$endif$
+  <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ - Kamailio Wiki</title>
+$for(css)$
+  <link rel="stylesheet" href="$css$" />
+$endfor$
+$if(math)$
+  $math$
+$endif$
+$for(header-includes)$
+  $header-includes$
+$endfor$
+<style>
+  #nav {
+    position: fixed;
+    top: 0;
+    left: 0;
+    /* padding: 10px; */
+    padding-left: 20px;
+    background-color: #FFF;
+    width: 100%;
+  }
+  #nav ul {
+    margin-left: 100px;
+    display: inline-block;
+    list-style: none;
+  }
+  #nav ul li {
+    margin-left: 20px;
+    display: inline-block;
+    list-style: none;
+  }
+</style>
+</head>
+<body>
+$for(include-before)$
+$include-before$
+$endfor$
+
+<header>
+<h1 class="title">$title$</h1>
+<blockquote class="metadata">
+$if(subtitle)$
+<p class="subtitle">$subtitle$</p>
+$endif$
+$if(author)$
+<p class="author">
+  $if(author-url)$
+    <a href="$author-url$">$author$</a>
+  $else$
+    $author$
+  $endif$
+</p>
+$endif$
+$if(date)$
+<p class="date $if(toc)$before-toc$endif$"><time datetime="$date$">$date$</time></p>
+$endif$
+</blockquote>
+</header>
+
+<div id="nav">
+  <ul style="float:right;padding-right:40px;">
+    <li>
+      <a href="https://github.com/kamailio/kamailio-wiki" target="_blank">GitHub</a>
+    </li>
+  </ul>
+  <a href="/">
+    <img src="https://www.kamailio.org/w/wp-content/uploads/2016/04/kamailio-logo-2015-140x64.png" alt="kamailio logo" id='logo'/>
+  </a>
+  <ul>
+    <li><a href="http://www.kamailio.org/" target="_blank">Kamailio Site</a></li>
+    <li><a href="http://www.kamailio.org/w/documentation/" target="_blank">Docs Index</a></li>
+    <li><a href="http://www.kamailio.org/docs/modules/" target="_blank">Module Docs</a></li>
+    <li><a href="http://www.kamailio.org/dokuwiki/" target="_blank">Old Wiki</a></li>
+  </ul>
+</div>
+
+$if(toc)$
+<nav id="$idprefix$TOC" role="doc-toc">
+  $if(return-url)$
+  <a href="$return-url$">$if(return-text)$$return-text$$else$← Return$endif$</a><br>
+  $endif$
+  <!-- <strong>Contents</strong><label for="contents">⊕</label> -->
+  <!-- <input type="checkbox" id="contents"> -->
+  $table-of-contents$
+</nav>
+$endif$
+
+<main>
+$body$
+</main>
+
+$if(return-url)$
+<footer>
+<p class="signoff">
+  <a href="$return-url$">$if(return-text)$$return-text$$else$← Return$endif$</a>
+</p>
+</footer>
+$endif$
+<script>
+;(function() {
+  // Non-essential if user has JavaScript off. Just makes checkboxes look nicer.
+  var selector = '.task-list > li > input[type="checkbox"]';
+  var checkboxes = document.querySelectorAll(selector);
+  Array.from(checkboxes).forEach((checkbox) => {
+    var wasChecked = checkbox.checked;
+    checkbox.disabled = false;
+    checkbox.addEventListener('click', (ev) => {ev.target.checked = wasChecked});
+  });
+})();
+</script>
+$for(include-after)$
+$include-after$
+$endfor$
+</body>
+</html>