diff --git a/app.js b/app.js index 0f94044..787ecd1 100644 --- a/app.js +++ b/app.js @@ -84,7 +84,7 @@ function getAllBlogPosts(page = 1, postsPerPage = 5) { // Get the last modified date of the markdown file const stats = fs.statSync(path.join(__dirname, 'markdown', file)); - const dateCreated = new Date(stats.birthtime); // Use mtime for last modification time + const dateCreated = new Date(stats.birthtime); // Use birthtime for last modification time // Format the date const formattedDate = dateCreated.toLocaleDateString('en-US', { @@ -218,8 +218,8 @@ app.get('/sitemap.xml', (req, res) => { const blogFiles = fs.readdirSync(path.join(__dirname, 'markdown')) .filter(file => file.endsWith('.md')) .sort((a, b) => { - const statA = fs.statSync(path.join(__dirname, 'markdown', a)).mtime; - const statB = fs.statSync(path.join(__dirname, 'markdown', b)).mtime; + const statA = fs.statSync(path.join(__dirname, 'markdown', a)).birthtime; + const statB = fs.statSync(path.join(__dirname, 'markdown', b)).birthtime; return statB - statA; // Sort in descending order (latest first) }); @@ -237,7 +237,7 @@ app.get('/sitemap.xml', (req, res) => { // Get the last modified date of the markdown file const stats = fs.statSync(path.join(__dirname, 'markdown', file)); - const lastModifiedDate = format(new Date(stats.mtime), 'yyyy-MM-dd'); + const lastModifiedDate = format(new Date(stats.birthtime), 'yyyy-MM-dd'); return { url: `/blog/${slug}`, @@ -276,8 +276,8 @@ app.get('/rss', (req, res) => { const blogFiles = fs.readdirSync(path.join(__dirname, 'markdown')) .filter(file => file.endsWith('.md')) .sort((a, b) => { - const statA = fs.statSync(path.join(__dirname, 'markdown', a)).mtime; - const statB = fs.statSync(path.join(__dirname, 'markdown', b)).mtime; + const statA = fs.statSync(path.join(__dirname, 'markdown', a)).birthtime; + const statB = fs.statSync(path.join(__dirname, 'markdown', b)).birthtime; return statB - statA; // Sort in descending order (latest first) }); @@ -294,7 +294,7 @@ app.get('/rss', (req, res) => { // Get the last modified date of the markdown file const stats = fs.statSync(path.join(__dirname, 'markdown', file)); - const lastModifiedDate = new Date(stats.mtime).toUTCString(); // Use UTC date for RSS + const lastModifiedDate = new Date(stats.birthtime).toUTCString(); // Use UTC date for RSS // Load and parse markdown content to extract a lead or description const { lead } = loadMarkdownWithLead(file);