@ryan-henness-trimble/mini-docs
Advanced tools
Comparing version 0.0.0-beta.1 to 0.0.0-beta.2
@@ -10,2 +10,3 @@ #!/usr/bin/env node | ||
.requiredOption('-o, --output <output>', 'Output directory') | ||
.option('-b, --base-url-path <baseUrlPath>', 'base URL path for generated documentation', '/') | ||
.parse(process.argv); | ||
@@ -15,3 +16,3 @@ | ||
const fileSystemStructure = generateFileSystemStructure(options.input, options.input); | ||
const fileSystemStructure = generateFileSystemStructure(options.input, options.input, options.baseUrlPath); | ||
generateIndexPage(fileSystemStructure, options.output).then(() => { | ||
@@ -18,0 +19,0 @@ generatePages(fileSystemStructure, options.output, fileSystemStructure).then(() => { |
@@ -35,7 +35,7 @@ "use strict"; | ||
const INDEX_TEMPLATE_PATH = path_1.default.resolve(__dirname, 'templates/index.ejs'); | ||
const generateFileSystemStructure = (rootPath, inputPath) => { | ||
const generateFileSystemStructure = (rootPath, inputPath, basePath) => { | ||
const stats = fs.statSync(inputPath); | ||
const fileName = path_1.default.basename(inputPath); | ||
const name = convertKebabToWords(fileName).replace(MD_EXTENSION, ''); | ||
const relativePath = `/${path_1.default.relative(rootPath, inputPath).replace(/\\/g, '/')}`; | ||
const relativePath = `${basePath}${path_1.default.relative(rootPath, inputPath).replace(/\\/g, '/')}`; | ||
if (stats.isFile()) { | ||
@@ -61,3 +61,3 @@ return { | ||
const itemPath = path_1.default.join(inputPath, item); | ||
directory.contents.push(generateFileSystemStructure(rootPath, itemPath)); | ||
directory.contents.push(generateFileSystemStructure(rootPath, itemPath, basePath)); | ||
} | ||
@@ -106,2 +106,3 @@ return directory; | ||
exports.generatePages = generatePages; | ||
// TODO - Create a better index page. This is just a placeholder. | ||
const generateIndexPage = (sidenavContents, outputPath) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -108,0 +109,0 @@ if (sidenavContents.type === 'file') { |
{ | ||
"name": "@ryan-henness-trimble/mini-docs", | ||
"version": "0.0.0-beta.1", | ||
"version": "0.0.0-beta.2", | ||
"description": "", | ||
@@ -33,2 +33,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@ryan-henness-trimble/mini-docs": "^0.0.0-beta.1", | ||
"@types/ejs": "^3.1.5", | ||
@@ -35,0 +36,0 @@ "@types/fs-extra": "^11.0.4", |
@@ -10,2 +10,3 @@ #!/usr/bin/env node | ||
.requiredOption('-o, --output <output>', 'Output directory') | ||
.option('-b, --base-url-path <baseUrlPath>', 'base URL path for generated documentation', '/') | ||
.parse(process.argv); | ||
@@ -15,3 +16,3 @@ | ||
const fileSystemStructure = generateFileSystemStructure(options.input, options.input); | ||
const fileSystemStructure = generateFileSystemStructure(options.input, options.input, options.baseUrlPath); | ||
generateIndexPage(fileSystemStructure, options.output).then(() => { | ||
@@ -18,0 +19,0 @@ generatePages(fileSystemStructure, options.output, fileSystemStructure).then(() => { |
@@ -40,7 +40,7 @@ const fs = require('fs-extra'); | ||
const generateFileSystemStructure = (rootPath: string, inputPath: string): Directory | File => { | ||
const generateFileSystemStructure = (rootPath: string, inputPath: string, basePath: string): Directory | File => { | ||
const stats = fs.statSync(inputPath); | ||
const fileName = path.basename(inputPath); | ||
const name = convertKebabToWords(fileName).replace(MD_EXTENSION, ''); | ||
const relativePath = `/${path.relative(rootPath, inputPath).replace(/\\/g, '/')}`; | ||
const relativePath = `${basePath}${path.relative(rootPath, inputPath).replace(/\\/g, '/')}`; | ||
@@ -69,3 +69,3 @@ if (stats.isFile()) { | ||
const itemPath = path.join(inputPath, item); | ||
directory.contents.push(generateFileSystemStructure(rootPath, itemPath)); | ||
directory.contents.push(generateFileSystemStructure(rootPath, itemPath, basePath)); | ||
} | ||
@@ -72,0 +72,0 @@ |
48378
21
305
9