Make sure that news entries are not overwritten

mdx-conversion
Aditya Thakral 1 year ago
parent 6b301accc1
commit 78b1134a43
  1. 20
      scripts/mdx-scripts/news-conversion.js

@ -1,4 +1,5 @@
const fs = require("fs");
const crypto = require('crypto')
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { window } = new JSDOM("");
@ -57,21 +58,22 @@ date: '${(new Date(date + ' EST').toString())}'
---
${content}`;
const mdTitle = `${date}-${author}`;
fs.mkdirSync(
`./markdown-news/${currentTerm.year}/${currentTerm.term}`,
{ recursive: true },
(err) => {
if (err) throw err;
}
);
fs.writeFileSync(
`./markdown-news/${currentTerm.year}/${currentTerm.term}/${mdTitle}.md`,
md,
(err) => {
if (err) throw err;
}
},
);
const path = `./markdown-news/${currentTerm.year}/${
currentTerm.term
}/${date}-${author}-${crypto.randomUUID().slice(0, 6)}.md`;
fs.writeFileSync(path, md, (err) => {
if (err) throw err;
});
}
});
};

Loading…
Cancel
Save