single-page-markdown-website
Version:
Create a nice single-page documentation website from one or more Markdown files
17 lines • 681 B
JavaScript
import path from 'path';
const imagesDirectoryName = 'images';
export function resolveNewImageFilePath(imageSrc, usedFilePaths) {
let newFilePath = path.join(imagesDirectoryName, path.basename(imageSrc));
if (usedFilePaths.indexOf(newFilePath) === -1) {
return newFilePath;
}
const extension = path.extname(newFilePath);
const basename = path.basename(newFilePath, extension);
let index = 0;
do {
index += 1;
newFilePath = path.join(imagesDirectoryName, `${basename}-${index}${extension}`);
} while (usedFilePaths.indexOf(newFilePath) !== -1);
return newFilePath;
}
//# sourceMappingURL=resolve-new-image-file-path.js.map