From ac4cd9cba6cdccb65d82596a90f4b3f7a87618ba Mon Sep 17 00:00:00 2001 From: Knight Date: Sat, 28 Dec 2024 10:39:29 -0500 Subject: [PATCH] Refactor generateSite.js to use ES module syntax. Updated import statements and added support for obtaining the current directory name using fileURLToPath. This change aligns with the recent addition of "type": "module" in package.json. --- generateSite.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/generateSite.js b/generateSite.js index 2e3a236..8016862 100644 --- a/generateSite.js +++ b/generateSite.js @@ -1,6 +1,10 @@ -const fs = require('fs').promises; -const path = require('path'); -const http = require('http'); +import { promises as fs } from 'fs'; +import path from 'path'; +import http from 'http'; +import { fileURLToPath } from 'url'; + +// Get current directory name in ES modules +const __dirname = path.dirname(fileURLToPath(import.meta.url)); async function generateSite() { // Read the images data