gitbook-plugin-blackbeard
Advanced tools
Comparing version 1.0.1 to 1.0.2
17
index.js
"use strict"; | ||
let references = {}; | ||
let configRefs = {}; | ||
const slug = require("slug"); | ||
const path = require("path"); | ||
@@ -28,6 +27,9 @@ | ||
module.exports = { | ||
book: {}, | ||
hooks: { | ||
init: function() { | ||
configRefs = this.options.pluginsConfig.references || {} | ||
}, | ||
"page:before": function(page) { | ||
const frontpageLink = "/" + require("path").relative(page.path, "docs"); | ||
const frontpageLink = path.relative(path.dirname(page.path), "."); | ||
@@ -80,5 +82,10 @@ let content, references; | ||
for(let key in configRefs) { | ||
references[key] = path.relative(path.dirname(page.path), path.dirname(configRefs[key])); | ||
references[key] = path.join(references[key], path.basename(configRefs[key])); | ||
} | ||
for(let key in references) { | ||
let link = references[key]; | ||
link = link.indexOf("/") !== -1 ? link : `#${link}`; | ||
link = link.indexOf("/") !== -1 || link.indexOf(".html") !== -1 ? link : `#${link}`; | ||
@@ -85,0 +92,0 @@ content += `[\`${key}\`]: ${link}\n`; |
@@ -6,2 +6,4 @@ "use strict"; | ||
const marked = require("marked"); | ||
/** | ||
@@ -46,3 +48,3 @@ * Generates a table of contents for Markdown files | ||
return `<${header} id="${slug}">${$2}</${header}>\n`; | ||
return `<${header} id="${slug}">${marked($2)}</${header}>\n`; | ||
} | ||
@@ -49,0 +51,0 @@ |
@@ -9,3 +9,5 @@ { | ||
"description": "Blackbeard documentation plugin for Gitbook", | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"marked": "^0.3.5" | ||
}, | ||
"directories": {}, | ||
@@ -20,3 +22,3 @@ "engines": { | ||
"scripts": {}, | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"repository": { | ||
@@ -23,0 +25,0 @@ "type": "git", |
26341
229
1