Compare commits
No commits in common. "0c9279805e16d43c8269bee15a13bbd79d8ce30d" and "5a956cb70856ce73b949ca9c6f0919b3f7b5bc36" have entirely different histories.
0c9279805e
...
5a956cb708
7
app.js
7
app.js
@ -103,11 +103,6 @@ function getAllBlogPosts(page = 1, postsPerPage = 5) {
|
|||||||
// Home Route (Blog Home with Pagination)
|
// Home Route (Blog Home with Pagination)
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
const page = parseInt(req.query.page) || 1;
|
const page = parseInt(req.query.page) || 1;
|
||||||
|
|
||||||
if (page < 1) {
|
|
||||||
return res.redirect(req.hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
const postsPerPage = 5; // Set how many posts to display per page
|
const postsPerPage = 5; // Set how many posts to display per page
|
||||||
|
|
||||||
const { blogPosts, totalPages } = getAllBlogPosts(page, postsPerPage);
|
const { blogPosts, totalPages } = getAllBlogPosts(page, postsPerPage);
|
||||||
@ -190,7 +185,7 @@ app.post('/contact', (req, res) => {
|
|||||||
app.get('/blog/:slug', (req, res) => {
|
app.get('/blog/:slug', (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);
|
||||||
|
|
||||||
if (markdownFile) {
|
if (markdownFile) {
|
||||||
const originalTitle = markdownFile.replace('.md', ''); // Original title with casing
|
const originalTitle = markdownFile.replace('.md', ''); // Original title with casing
|
||||||
|
Loading…
Reference in New Issue
Block a user