hmm
This commit is contained in:
33
fix-dates.js
33
fix-dates.js
@@ -1,13 +1,16 @@
|
|||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises');
|
||||||
|
|
||||||
|
|
||||||
async function run() {
|
async function renamemarkdown() {
|
||||||
const files = await fs.readdir('./content/blog');
|
const files = await fs.readdir('./content/blog');
|
||||||
console.log(files);
|
|
||||||
|
|
||||||
await Promise.all(files
|
await Promise.all(files
|
||||||
.filter(file => file.endsWith('.md'))
|
.filter(file => file.toLowerCase().endsWith('.md'))
|
||||||
.map(async (file) => {
|
.map(async (file) => {
|
||||||
|
const computedDirectory = file.replace('.md', '').replace('.MD', '')
|
||||||
|
await fs.rename(`./content/blog/${file}`, `./content/blog/${file}-bkp`)
|
||||||
|
await fs.mkdir(`./content/blog/${file}`)
|
||||||
|
await fs.rename(`./content/blog/${file}-bkp`, `./content/blog/${computedDirectory}/${file}`)
|
||||||
// const fileContent = await fs.readFile(file, 'utf8');
|
// const fileContent = await fs.readFile(file, 'utf8');
|
||||||
// regex find the line date:
|
// regex find the line date:
|
||||||
// const date = fileContent.match(/date: (.*)/);
|
// const date = fileContent.match(/date: (.*)/);
|
||||||
@@ -15,4 +18,26 @@ async function run() {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
// async function MoveImages() {
|
||||||
|
// const dirs = await fs.readdir('./content/img');
|
||||||
|
// const blogDirs = await fs.readdir('./content/blog');
|
||||||
|
// dirs
|
||||||
|
// .filter(dir => !blogDirs.includes(dir))
|
||||||
|
// .map(async dir => {
|
||||||
|
// // get all files in dir
|
||||||
|
// const files = await fs.readdir(`./content/img/${dir}`);
|
||||||
|
// await Promise.all(
|
||||||
|
// files.map(async subfile => {
|
||||||
|
// await fs.rename(`./content/img/${dir}/${subfile}`, `./content/blog/${dir}/${subfile}`)
|
||||||
|
// })
|
||||||
|
// )
|
||||||
|
// const hasFiles = (await fs.readdir(`./content/img/${dir}`)).length > 0;
|
||||||
|
// if(!hasFiles) {
|
||||||
|
// await fs.rmdir(`./content/img/${dir}`)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
renamemarkdown();
|
||||||
|
|
||||||
|
// MoveImages();
|
||||||
|
|||||||
Reference in New Issue
Block a user