(sourceDir, file, targetDir)
| 68 | }; |
| 69 | |
| 70 | const copyAssetsAndWriteFile = async (sourceDir, file, targetDir) => { |
| 71 | const sourcePath = path.join(sourceDir, file); |
| 72 | const targetPath = path.join(targetDir, file).replace(/\.md$/, '.html'); |
| 73 | const markdown = (await fs.readFile(sourcePath)).toString(); |
| 74 | const awaits = await copyAssetsFromOptions(markdown); |
| 75 | const base = relativeDir(file, '.'); |
| 76 | const markup = await renderFile(path.join(sourceDir, file), { base }); |
| 77 | |
| 78 | const markdownImages = markdown.matchAll(markdownImageRE); |
| 79 | const htmlImages = markdown.matchAll(htmlImageRE); |
| 80 | const backgroundImages = markdown.matchAll(markdownImageBackgroundRE); |
| 81 | const allImages = [...markdownImages, ...htmlImages, ...backgroundImages]; |
| 82 | |
| 83 | for (let image of allImages) { |
| 84 | const [, imgPath] = image; |
| 85 | if (!isAbsoluteURL(imgPath)) { |
| 86 | const relPath = path.join(path.dirname(file), imgPath); |
| 87 | awaits.push(cp(path.join(sourceDir, relPath), path.join(targetDir, relPath)).catch(err => console.warn(err))); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | awaits.push(write(targetPath, markup)); |
| 92 | awaits.push(featuredSlide(file, path.join(targetDir, path.dirname(file)))); |
| 93 | return Promise.all(awaits); |
| 94 | }; |
| 95 | |
| 96 | const writeMarkupFiles = async (sourceDir, targetDir) => { |
| 97 | if (await isDirectory(sourceDir)) { |
no test coverage detected