revert
This commit is contained in:
parent
0a84015943
commit
05455191f5
16
app.js
16
app.js
@ -206,18 +206,8 @@ app.post('/contact', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Blog Post Route for new URLs (without /blog prefix)
|
// Blog Post Route
|
||||||
app.get('/:slug', (req, res) => {
|
|
||||||
handleBlogPost(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Blog Post Route for old URLs (with /blog prefix)
|
|
||||||
app.get('/blog/:slug', (req, res) => {
|
app.get('/blog/:slug', (req, res) => {
|
||||||
handleBlogPost(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function to handle blog posts (used in both routes)
|
|
||||||
function handleBlogPost(req, res) {
|
|
||||||
const slug = req.params.slug;
|
const slug = req.params.slug;
|
||||||
const markdownFile = fs.readdirSync(path.join(__dirname, 'markdown'))
|
const markdownFile = fs.readdirSync(path.join(__dirname, 'markdown'))
|
||||||
.find(file => titleToSlug(file.replace('.md', '')) === slug);
|
.find(file => titleToSlug(file.replace('.md', '')) === slug);
|
||||||
@ -236,7 +226,9 @@ function handleBlogPost(req, res) {
|
|||||||
} else {
|
} else {
|
||||||
res.redirect('/'); // Redirect to the home page if the blog post is not found
|
res.redirect('/'); // Redirect to the home page if the blog post is not found
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
// Sitemap Route
|
||||||
// Sitemap Route
|
// Sitemap Route
|
||||||
app.get('/sitemap.xml', (req, res) => {
|
app.get('/sitemap.xml', (req, res) => {
|
||||||
const hostname = req.headers.host || 'http://localhost'; // Ensure this is your site URL in production
|
const hostname = req.headers.host || 'http://localhost'; // Ensure this is your site URL in production
|
||||||
|
Loading…
Reference in New Issue
Block a user