Skip to content

Commit 6f702b9

Browse files
committed
Redirects: Add support for setting redirects in redirects.json
1 parent 3f94a5d commit 6f702b9

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"marked": "0.3.2",
3030
"rimraf": "2.2.8",
3131
"spawnback": "1.0.0",
32-
"which": "1.0.5"
32+
"which": "1.0.5",
33+
"wordpress": "0.1.3"
3334
},
3435
"devDependencies": {
3536
"grunt": "0.4.5",

tasks/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ grunt.registerTask( "clean-dist", function() {
1818
// Define an empty lint task, to be redefined by each site with relevant lint tasks
1919
grunt.registerTask( "lint", [] );
2020

21-
grunt.registerTask( "build-wordpress", [ "check-modules", "lint", "clean-dist", "build" ] );
21+
grunt.registerTask( "build-wordpress", [ "check-modules", "lint", "clean-dist", "build", "redirects" ] );
2222

2323
grunt.registerMultiTask( "build-posts", "Process html and markdown files as posts", function() {
2424
var task = this,

tasks/redirects.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = function( grunt ) {
2+
3+
var wp = require( "wordpress" );
4+
5+
grunt.registerTask( "redirects", function() {
6+
var config = grunt.config( "wordpress" ),
7+
redirects = grunt.file.exists( "redirects.json" ) ? grunt.file.readJSON( "redirects.json" ) : {},
8+
client = wp.createClient( config );
9+
10+
client.authenticatedCall( "jq.setRedirects", JSON.stringify( redirects ), this.async() );
11+
});
12+
13+
};

0 commit comments

Comments
 (0)