change from mtime to dateCreated
This commit is contained in:
parent
aed95beea1
commit
18a427c7b0
14
app.js
14
app.js
@ -84,7 +84,7 @@ function getAllBlogPosts(page = 1, postsPerPage = 5) {
|
|||||||
|
|
||||||
// Get the last modified date of the markdown file
|
// Get the last modified date of the markdown file
|
||||||
const stats = fs.statSync(path.join(__dirname, '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
|
// Format the date
|
||||||
const formattedDate = dateCreated.toLocaleDateString('en-US', {
|
const formattedDate = dateCreated.toLocaleDateString('en-US', {
|
||||||
@ -218,8 +218,8 @@ app.get('/sitemap.xml', (req, res) => {
|
|||||||
const blogFiles = fs.readdirSync(path.join(__dirname, 'markdown'))
|
const blogFiles = fs.readdirSync(path.join(__dirname, 'markdown'))
|
||||||
.filter(file => file.endsWith('.md'))
|
.filter(file => file.endsWith('.md'))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const statA = fs.statSync(path.join(__dirname, 'markdown', a)).mtime;
|
const statA = fs.statSync(path.join(__dirname, 'markdown', a)).birthtime;
|
||||||
const statB = fs.statSync(path.join(__dirname, 'markdown', b)).mtime;
|
const statB = fs.statSync(path.join(__dirname, 'markdown', b)).birthtime;
|
||||||
return statB - statA; // Sort in descending order (latest first)
|
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
|
// Get the last modified date of the markdown file
|
||||||
const stats = fs.statSync(path.join(__dirname, '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 {
|
return {
|
||||||
url: `/blog/${slug}`,
|
url: `/blog/${slug}`,
|
||||||
@ -276,8 +276,8 @@ app.get('/rss', (req, res) => {
|
|||||||
const blogFiles = fs.readdirSync(path.join(__dirname, 'markdown'))
|
const blogFiles = fs.readdirSync(path.join(__dirname, 'markdown'))
|
||||||
.filter(file => file.endsWith('.md'))
|
.filter(file => file.endsWith('.md'))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const statA = fs.statSync(path.join(__dirname, 'markdown', a)).mtime;
|
const statA = fs.statSync(path.join(__dirname, 'markdown', a)).birthtime;
|
||||||
const statB = fs.statSync(path.join(__dirname, 'markdown', b)).mtime;
|
const statB = fs.statSync(path.join(__dirname, 'markdown', b)).birthtime;
|
||||||
return statB - statA; // Sort in descending order (latest first)
|
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
|
// Get the last modified date of the markdown file
|
||||||
const stats = fs.statSync(path.join(__dirname, '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
|
// Load and parse markdown content to extract a lead or description
|
||||||
const { lead } = loadMarkdownWithLead(file);
|
const { lead } = loadMarkdownWithLead(file);
|
||||||
|
Loading…
Reference in New Issue
Block a user