Comparing version 0.0.5 to 0.0.6
@@ -6,2 +6,3 @@ | ||
var wrench = require("wrench") | ||
var path = require("path") | ||
var fs = require("fs") | ||
@@ -53,2 +54,4 @@ | ||
var lastIndex = 0 | ||
for(var j = 0 ; j < page.menu.length ; j++) { | ||
@@ -59,3 +62,10 @@ var menuItem = page.menu[j] | ||
console.log("replacing ["+menuItem.original+"] with ["+replaceString+"]") | ||
page.htmlContent = page.htmlContent.replace(menuItem.original, replaceString) | ||
var index = page.htmlContent.indexOf(menuItem.original, lastIndex); | ||
if(index !== -1) { | ||
page.htmlContent = page.htmlContent.substring(0, index) + replaceString + page.htmlContent.substring(index + menuItem.original.length, page.htmlContent.length) | ||
lastIndex = index; | ||
} | ||
} | ||
@@ -70,2 +80,23 @@ | ||
} | ||
if(manifest.sections) { | ||
for(var j = 0 ; j < manifest.sections.length ; j++) { | ||
var section = manifest.sections[j] | ||
if(section.title === page.section) { | ||
console.log("** Adding page ["+page.title+"] to section ["+section.title+"]") | ||
if(!section.pages) { | ||
section.pages = [] | ||
} | ||
section.pages.push(page) | ||
break | ||
} | ||
} | ||
} | ||
} | ||
@@ -79,2 +110,4 @@ | ||
copyAssets(manifest, path.dirname(manifestFilePath), outputDir) | ||
compilePages(outputDir, manifest, theme, function(err) { | ||
@@ -91,2 +124,19 @@ if(err) { | ||
function copyAssets(manifest, sourceDir, outputDir) { | ||
if(manifest.assets) { | ||
var assetsDir = outputDir+"/assets/" | ||
if(!fs.existsSync(assetsDir)) { | ||
console.log("Creating directory ["+assetsDir+"]") | ||
fs.mkdirSync(assetsDir) | ||
} | ||
for(var i = 0 ; i < manifest.assets.length ; i++) { | ||
var asset = manifest.assets[i] | ||
fs.createReadStream(process.env.PWD + "/" + asset).pipe(fs.createWriteStream(assetsDir+path.basename(asset))); | ||
} | ||
} | ||
} | ||
function loadTemplate(theme) { | ||
@@ -147,2 +197,5 @@ // TODO: make template configurable | ||
var reservedMenuIds = {} | ||
var count = 1; | ||
while(result !== null) { | ||
@@ -157,6 +210,15 @@ | ||
level: level, | ||
original: result[0], | ||
id: result[2].replace(/[^a-z0-9]/ig, "_") | ||
original: result[0] | ||
} | ||
var menuId = result[2].replace(/[^a-z0-9]/ig, "_") | ||
if(reservedMenuIds.hasOwnProperty(menuId)) { | ||
reservedMenuIds[menuId] ++ | ||
menuId = menuId + "_" + reservedMenuIds[menuId] | ||
} else { | ||
reservedMenuIds[menuId] = 0 | ||
} | ||
menuItem.id = menuId | ||
menu.push(menuItem) | ||
@@ -163,0 +225,0 @@ } |
{ | ||
"name": "doctasia", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Nicolas Herment <nherment@gmail.com>", | ||
@@ -5,0 +5,0 @@ "preferGlobal": "true", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2744178
205
54486
3