Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Add support for robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed May 8, 2017
1 parent 9e6326c commit 749ba8c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions source/controllers/theme/robots_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

// Node modules
const Promise = require('bluebird');

module.exports = {

//
// Renders the robots.txt page.
//
view: (req, res, next) => {
Promise.resolve()
.then(() => {
res.header('Content-Type', 'text/plain').render('robots');
})
.catch((err) => next(err));
}

};
8 changes: 8 additions & 0 deletions source/routers/theme_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = (app) => {
const BlogController = require(Path.join(__basedir, 'source/controllers/theme/blog_controller.js'));
const FeedController = require(Path.join(__basedir, 'source/controllers/theme/feed_controller.js'));
const PostController = require(Path.join(__basedir, 'source/controllers/theme/post_controller.js'));
const RobotsController = require(Path.join(__basedir, 'source/controllers/theme/robots_controller.js'));
const SearchController = require(Path.join(__basedir, 'source/controllers/theme/search_controller.js'));
const TagController = require(Path.join(__basedir, 'source/controllers/theme/tag_controller.js'));

Expand Down Expand Up @@ -126,6 +127,13 @@ module.exports = (app) => {
//
router.get('/:slug', PostController.view);

//
// Robots
//
// GET /robot.txt
//
app.use('/robots.txt', RobotsController.view);

// Attach the router to the app
app.use(
'/',
Expand Down
2 changes: 2 additions & 0 deletions source/views/robots.dust
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: {@url type="admin"/}

0 comments on commit 749ba8c

Please # to comment.