Created
June 8, 2017 14:40
-
-
Save andreasvirkus/dd1f60fe91dd518b36310d19f2f563cd to your computer and use it in GitHub Desktop.
Simple Metalsmith robots.txt plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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