This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const buildPaths = (newArticleFolderPath: string): ArticlePaths => { | |
| const imageExtension: string = getImageExtension(); | |
| const imageCoverFileName: string = `cover.${imageExtension}`; | |
| const newArticlePath: string = `${newArticleFolderPath}/index.html`; | |
| const imageCoverExamplePath: string = resolve(__dirname, `../examples/${imageCoverFileName}`); | |
| const assetsFolder: string = `${newArticleFolderPath}/assets`; | |
| const imageCoverPath: string = `${assetsFolder}/${imageCoverFileName}`; | |
| return { | |
| newArticlePath, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| await copyFile(imageCoverExamplePath, imageCoverPath); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| await mkdir(assetsFolder, { recursive: true }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const imageCoverPath: string = `${assetsFolder}/${imageCoverFileName}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const imageCoverExamplePath: string = resolve(__dirname, `../examples/${imageCoverFileName}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assetsFolder: string = `${newArticleFolderPath}/assets`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2020/04/publisher-a-tooling-to-blog-post-publishing/assets/cover.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const newArticlePath: string = `${newArticleFolderPath}/index.html`; | |
| await writeFile(newArticlePath, article); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const newArticleFolderPath: string = buildNewArticleFolderPath(articleConfig); | |
| await mkdir(newArticleFolderPath, { recursive: true }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const buildNewArticleFolderPath = ({ title, date }: { title: string, date: string }): string => { | |
| const [year, month]: string[] = date.split('-'); | |
| const slugifiedTitle: string = slugify(title); | |
| return resolve(__dirname, `../../${year}/${month}/${slugifiedTitle}`); | |
| }; |