forked from less/less-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
172 lines (151 loc) · 4.3 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* lesscss.org
* https://github.com/less/less-docs
* Copyright (c) 2013
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Project metadata
pkg: grunt.file.readJSON('package.json'),
site: grunt.file.readYAML('_config.yml'),
jshint: {
options: {jshintrc: '.jshintrc'},
all: [
'Gruntfile.js',
'templates/helpers/*.js'
]
},
// Pull down a JSON list of repos from the Less org, using
// GitHub's API (to be passed as context into the templates)
repos: {
namespaced: {
options: {username: 'less'},
files: {
'<%= site.data %>/less.json': ['repos?page=1&per_page=100']
}
}
},
// Build HTML from templates and data
assemble: {
options: {
flatten: true,
production: false,
assets: '<%= site.dest %>/public',
// Metadata
pkg: '<%= pkg %>',
site: '<%= site %>',
data: ['<%= site.data %>/*.{json,yml}', 'content/**/*.json'],
// Extensions
plugins: '<%= site.plugins %>',
helpers: ['<%= site.helpers %>/*.js'],
// Helper options
compose: {cwd: 'content'},
marked: {
process: true,
heading: '<%= site.markedtemplates %>/heading.tmpl',
// highlight.js options
prefix: 'lang-'
},
// Templates
partials: '<%= site.includes %>/*.hbs',
layoutdir: '<%= site.layouts %>',
layoutext: '<%= site.layoutext %>',
layout: '<%= site.layout %>'
},
site: {
options: {
partials: ['content/**/*.md'],
permalinks: {preset: 'pretty'}
},
src: '<%= site.pages %>/*.hbs',
dest: '<%= site.dest %>/'
},
feed: {
options: {
ext: '.xml',
layout: 'none'
},
src: '<%= site.pages %>/feed.xml',
dest: '<%= site.dest %>/'
}
},
prettify: {
site: {
files: [
{expand: true, cwd: '<%= site.dest %>', src: '*.html', dest: '<%= site.dest %>/', ext: '.html'}
]
}
},
connect: {
options: {
port: 3000,
livereload: 35729,
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: ['<%= site.dest %>']
}
}
},
// Compile Less to CSS
less: {
options: {
paths: ['styles/bootstrap', 'styles/components']
},
site: {
src: ['styles/index.less'],
dest: '<%= assemble.options.assets %>/css/index.css'
}
},
// Copy source assets to _gh_pages
copy: {
assets: {
files: [
{expand: true, cwd: '<%= site.assets %>/public', src: ['**'], dest: '<%= site.dest %>/public/'},
{expand: true, cwd: '<%= site.assets %>/root', src: ['*'], dest: '<%= site.dest %>/', rename: function(dest, src) {
dest = dest + src.replace(/^_/, '');
return dest;
}}
]
}
},
clean: {
example: ['<%= site.dest %>/*']
},
watch: {
options: {livereload: true},
site: {
files: [
'<%= site.helpers %>',
'<%= site.styles %>/**/*.less',
'<%= site.templates %>/**/*.hbs',
'<%= site.content %>/**/*.md',
'<%= site.content %>/_config.yml',
'<%= site.data %>/*.yml',
'<%= site.data %>/*.json'
],
tasks: ['clean', 'copy', 'less:site', 'assemble']
}
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-prettify');
grunt.loadNpmTasks('grunt-repos');
grunt.loadNpmTasks('grunt-sync-pkg');
grunt.registerTask('update', ['repos', 'default']);
grunt.registerTask('design', ['clean', 'copy', 'less:site', 'assemble:site', 'connect', 'watch']);
// Default tasks to be run.
grunt.registerTask('default', ['jshint', 'clean', 'copy', 'less:site', 'assemble:site']);
};