Skip to content

Commit

Permalink
handle for non existing dir
Browse files Browse the repository at this point in the history
  • Loading branch information
UmairJibran committed Jan 14, 2025
1 parent 9ea761a commit f089f2a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 193 deletions.
191 changes: 0 additions & 191 deletions public/rss.xml

This file was deleted.

24 changes: 22 additions & 2 deletions scripts/generate-rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,28 @@ function escapeXML(str) {
}

function generateRSS() {
const blogFiles = fs.readdirSync(BLOGS_DIR);
const caseStudyFiles = fs.readdirSync(CASE_STUDIES_DIR);
let blogFiles = [];
let caseStudyFiles = [];

try {
if (fs.existsSync(BLOGS_DIR)) {
blogFiles = fs.readdirSync(BLOGS_DIR);
} else {
console.warn("Blogs directory does not exist:", BLOGS_DIR);
}
} catch (error) {
console.error("Error reading blogs directory:", error);
}

try {
if (fs.existsSync(CASE_STUDIES_DIR)) {
caseStudyFiles = fs.readdirSync(CASE_STUDIES_DIR);
} else {
console.warn("Case studies directory does not exist:", CASE_STUDIES_DIR);
}
} catch (error) {
console.error("Error reading case studies directory:", error);
}

const posts = blogFiles.map((file) => {
const filePath = path.join(BLOGS_DIR, file);
Expand Down

0 comments on commit f089f2a

Please sign in to comment.