idleman 9 months ago
parent
commit
ed1b73b7e9
3 changed files with 128 additions and 1 deletions
  1. 1 0
      _sidebar.md
  2. 74 0
      faq.md
  3. 53 1
      plugin.js

+ 1 - 0
_sidebar.md

@@ -3,3 +3,4 @@
 	* [Installation](install.md "Install")
 	* [Usage](usage.md)
 	* [Special syntax](special-syntax.md)
+	* [FAQ](faq.md)

+ 74 - 0
faq.md

@@ -0,0 +1,74 @@
+# FAQ
+
+All common questions / answer here
+
+## Summary
+
+[-FAQ-]
+
+---
+
+## Why red hook ?
+
+Remote docsify = Redoc = red hook, u got it ? :D
+
+## What is the licence of this bundle ? 
+
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+
+
+## What is the interest of this question? 
+
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+Honestly i dont care, [WTFPL](http://www.wtfpl.net/) seems to be the best
+> Dont forget to respect the docsify licence !
+
+
+## what is your favorite color ?
+
+Blue, no ! red ! aaaahhh

+ 53 - 1
plugin.js

@@ -5,7 +5,58 @@
       console.log(window.Docsify,vm);
     });
 
+    // hook.beforeEach(function (markdown) {
+
+    //     const tag =" [-FAQ-]";
+    //     console.log(markdown);
+
+    //     let tagPosition = markdown.indexOf(tag);
+    //     if(tagPosition===-1) return;
+
+    //     let toc = '> table of content : '+"\n";
+    //     toc += '* Title 1 '+"\n";
+    //     regex = new RegExp(tag,"i");
+    //     markdown = markdown.replace(regex,toc);
+
+    //     return markdown;
+    // });
+
     hook.afterEach(function (html) {
+
+
+        const tag ="[-FAQ-]";
+
+        let tagPosition = html.indexOf(tag);
+        if(tagPosition===-1) return;
+
+        let questionBlock = html.substr(tagPosition);
+
+        let toc = "<ul style='list-style-type:none;margin:0;padding:0'>";
+       
+        
+        const dom = document.createElement("div");
+        dom.innerHTML = questionBlock;
+    
+        let titles = dom.querySelectorAll('h2[id]');
+        for(var k in titles){
+          let title = titles[k];
+          if(!title.innerText ||  !title.id) continue;
+          let link = document.location.hash;
+          link = link.replace(/\?id=/,'');
+          link +='?id='+title.id;
+
+          toc += '<li>'+k+'. <a href="'+link+'">'+title.innerText+"</a></li>";
+        }
+        toc += "</ul>";
+        
+
+       
+        regex = new RegExp(tag,"i");
+        console.log(toc);
+        html = html.replace("\[\-FAQ\-\]",toc);
+
+        
+
         return html + 'Powered by redok';
     });
 
@@ -14,4 +65,5 @@
   // Add plugin to docsify's plugin array
   $docsify = $docsify || {};
   $docsify.plugins = [].concat($docsify.plugins || [], myPlugin);
-})();
+})();
+