Skip to content

Commit

Permalink
Fix filename
Browse files Browse the repository at this point in the history
  • Loading branch information
voiceinthedark committed Aug 3, 2023
1 parent 6c151cc commit ed8ca93
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ class App{
}

createFile(currentDirectory, fileName) {
const originalFilename = fileName;
// prefixes filename with the current date
fileName = `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}-${fileName}`;

const filePath = path.join(currentDirectory, fileName);
// fill the file with a YAML frontmatter
const data = `---\ntitle: ${fileName}\npublished_at: ${new Date().toISOString()}\nupdated_at: ${new Date().toISOString()}\ntype: article\ndescription: ${fileName}\nlink: /${new Date().getFullYear()}/${fileName}\nimage:\ntags:[]\n---`;
const data = `---\ntitle: ${originalFilename.split('.')[0]}\npublished_at: ${new Date().toISOString()}\nupdated_at: ${new Date().toISOString()}\ntype: article\ndescription: Enter description here\nlink: /${new Date().getFullYear()}/${originalFilename}\nimage: image.png\ntags: [tag1,tag2]\n---`;

fs.writeFile(filePath, data.trim(), err => {
if(err) {
Expand Down

0 comments on commit ed8ca93

Please sign in to comment.