diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-27 12:08:00 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-27 12:08:00 +0200 |
commit | 4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c (patch) | |
tree | 5966848cb10275d5aa93c4df2b1f208fd54ddb05 /lib/utils/location.js | |
parent | b05eb8440b59db6d39ae06712ddda5651786e00a (diff) | |
download | gitbook-4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c.zip gitbook-4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c.tar.gz gitbook-4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c.tar.bz2 |
Fix filters for theme templates
Diffstat (limited to 'lib/utils/location.js')
-rw-r--r-- | lib/utils/location.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/utils/location.js b/lib/utils/location.js index f1159f1..94d9b2a 100644 --- a/lib/utils/location.js +++ b/lib/utils/location.js @@ -71,11 +71,24 @@ function relative(dir, file) { return normalize(path.relative(dir, file)); } +/** + Convert an absolute path to a relative path for a specific folder (dir) + ('test/test.md', 'hello.md') -> '../hello.md' + + @param {String} baseFile: current file + @param {String} file: absolute path of file + @return {String} +*/ +function relativeForFile(baseFile, file) { + return relative(path.dirname(baseFile), file); +} + module.exports = { isExternal: isExternal, isRelative: isRelative, isAnchor: isAnchor, normalize: normalize, toAbsolute: toAbsolute, - relative: relative + relative: relative, + relativeForFile: relativeForFile }; |