Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created June 8, 2017 14:40
Show Gist options
  • Save andreasvirkus/dd1f60fe91dd518b36310d19f2f563cd to your computer and use it in GitHub Desktop.
Save andreasvirkus/dd1f60fe91dd518b36310d19f2f563cd to your computer and use it in GitHub Desktop.
Simple Metalsmith robots.txt plugin
import metalsmith from 'metalsmith';
import markdown from 'metalsmith-markdown';
import robots from './metalsmith-robots.js';
metalsmith(__dirname)
.use(markdown())
.use(robots({
source: 'sample-robots.txt'
})
.destination('./build');
export default function robots(opts) {
return function(files, metalsmith, done) {
fs.readFile(opts.source, function(err, data) {
files['robots.txt'] = {
contents: data
};
done();
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment