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 8620324 commit b8b8f5b
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 b8b8f5b

Please sign in to comment.