-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage-updater.js
40 lines (34 loc) · 1.03 KB
/
image-updater.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fs = require("fs");
const path = require("path");
const glob = require("glob");
// Define the path to the "content" folder
const dirPath = path.join(__dirname, "content");
// Get all .md files in the directory and its subdirectories
glob(`${dirPath}/**/*.md`, (err, files) => {
if (err) {
console.error(err);
return;
}
// Go through each file
files.forEach((file) => {
// Read the file's content
fs.readFile(file, "utf8", (err, data) => {
if (err) {
console.error(err);
return;
}
// Replace all instances of "https://photostma.blob.core.windows.net/web" with "http://images.thematchartist.com"
const result = data.replace(
/https:\/\/photostma\.blob\.core\.windows\.net\/web/g,
"https://images.thematchartist.com"
);
// Write the modified content back to the file
fs.writeFile(file, result, "utf8", (err) => {
if (err) {
console.error(err);
}
});
});
});
});
console.log("Image URLs updated successfully!");