Skip to content

Commit

Permalink
refactor & add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed May 31, 2018
1 parent c9e8f9f commit a2318ec
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/server/readMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,11 @@ function processMetadata(file) {
throw new Error('Document id cannot include "/".');
}

// if file is located in subdirectory,
// it will have the directory name appended to it's id
const relativeFile = path.relative(
path.join(CWD, '../', getDocsPath()),
file
// If a doc file is located in a subdirectory, prepend the subdir to it's ID
// Example: `docs/projectA/test.md` with 'test' ID is changed to `projectA/test`
const curDir = path.dirname(
path.relative(path.join(CWD, '../', getDocsPath()), file)
);
const curDir = path.dirname(relativeFile);
if (curDir !== '.') {
metadata.id = curDir + '/' + metadata.id;
metadata.source = curDir + '/' + metadata.source;
Expand Down

0 comments on commit a2318ec

Please sign in to comment.