Skip to content

Commit

Permalink
Regenerate blog metadata on request to blog (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun authored Apr 23, 2018
1 parent 266b374 commit d3fd347
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,16 @@ function execute(port) {
res.send(feed('rss'));
});

// handle all requests for blog pages and posts
// Handle all requests for blog pages and posts.
app.get(/blog\/.*html$/, (req, res) => {
// generate all of the blog pages
// Regenerate the blog metadata in case it has changed. Consider improving
// this to regenerate on file save rather than on page request.
reloadMetadataBlog();
// Generate all of the blog pages.
removeModuleAndChildrenFromCache(join('..', 'core', 'BlogPageLayout.js'));
const BlogPageLayout = require(join('..', 'core', 'BlogPageLayout.js'));
const blogPages = {};
// make blog pages with 10 posts per page
// Make blog pages with 10 posts per page.
const perPage = 10;
for (
let page = 0;
Expand Down Expand Up @@ -535,7 +538,7 @@ function execute(port) {
console.error('No response');
}
} else {
console.error('request failed:', err);
console.error('Request failed:', err);
}
}
);
Expand Down

0 comments on commit d3fd347

Please sign in to comment.