File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,35 @@ grunt.initConfig({
3838 } , grunt . file . readJSON ( "config.json" ) )
3939} ) ;
4040
41+ grunt . registerTask ( "manifest" , "Generate categories.json manifest file" , function ( ) {
42+ var categories ,
43+ categoryPosts = { } ,
44+ done = this . async ( ) ;
45+
46+ categories = require ( "./" + grunt . config ( "wordpress.dir" ) + "/taxonomies" ) . category ;
47+ categories . forEach ( function ( category ) {
48+ category . posts = categoryPosts [ category . slug ] = [ ] ;
49+ } ) ;
50+
51+ grunt . helper ( "wordpress-walk-posts" , grunt . config ( "wordpress.dir" ) , function ( post , callback ) {
52+ if ( post . termSlugs && post . termSlugs . category ) {
53+ post . termSlugs . category . forEach ( function ( slug ) {
54+ categoryPosts [ slug ] . push ( post ) ;
55+ } ) ;
56+ }
57+ callback ( ) ;
58+ } , function ( error ) {
59+ if ( error ) {
60+ grunt . error . log ( error . message ) ;
61+ return done ( false ) ;
62+ }
63+
64+ grunt . file . write ( grunt . config ( "wordpress.dir" ) + "/categories.json" ,
65+ JSON . stringify ( categories , null , "\t" ) + "\n" ) ;
66+ done ( ) ;
67+ } ) ;
68+ } ) ;
69+
4170grunt . registerTask ( "default" , "build-wordpress" ) ;
4271grunt . registerTask ( "build" , "build-pages build-xml-entries build-xml-categories build-resources build-xml-full" ) ;
4372grunt . registerTask ( "build-wordpress" , "check-modules clean lint xmllint build" ) ;
You can’t perform that action at this time.
0 commit comments