mirror of
https://github.com/harivansh-afk/Austens-Wedding-Guide.git
synced 2026-04-17 03:03:43 +00:00
Imrpoved blogs page
This commit is contained in:
parent
8fd1ca8260
commit
108b4533e9
17 changed files with 689 additions and 112 deletions
33
scripts/download-images.js
Normal file
33
scripts/download-images.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import https from 'https';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const characters = ['lewis', 'willy', 'gus', 'wizard', 'clint'];
|
||||
const imagesDir = path.join(__dirname, '../public/images/blogs');
|
||||
|
||||
// Create the directory if it doesn't exist
|
||||
if (!fs.existsSync(imagesDir)) {
|
||||
fs.mkdirSync(imagesDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Download a placeholder image for each character
|
||||
characters.forEach(character => {
|
||||
const url = `https://via.placeholder.com/800x600.png?text=${character}`;
|
||||
const filePath = path.join(imagesDir, `${character}-blog.png`);
|
||||
|
||||
https.get(url, (response) => {
|
||||
const fileStream = fs.createWriteStream(filePath);
|
||||
response.pipe(fileStream);
|
||||
|
||||
fileStream.on('finish', () => {
|
||||
console.log(`Downloaded ${character}-blog.png`);
|
||||
fileStream.close();
|
||||
});
|
||||
}).on('error', (err) => {
|
||||
console.error(`Error downloading ${character}-blog.png:`, err.message);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue