Skip to content

Commit 4f76b98

Browse files
committed
Make contributor data available to hugo
1 parent 834c5f4 commit 4f76b98

File tree

4 files changed

+91
-249
lines changed

4 files changed

+91
-249
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ yarn-error.log
88
.vscode/
99
manifest.yml
1010
.imdone/
11-
11+
website/site/data/contributors.yml
1212
/coverage/

website/gulpfile.babel.js

+62-30
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import gulp from "gulp";
22
import cp from "child_process";
3-
import hugoBin from "hugo-bin"
3+
import hugoBin from "hugo-bin";
44
import gutil from "gulp-util";
55
import postcss from "gulp-postcss";
6+
import jsonToYaml from "gulp-json-to-yaml";
7+
import rename from "gulp-rename";
68
import cssImport from "postcss-import";
79
import neatgrid from "postcss-neat";
810
import nestedcss from "postcss-nested";
@@ -15,56 +17,87 @@ import BrowserSync from "browser-sync";
1517
import webpack from "webpack";
1618
import webpackConfig from "./webpack.conf";
1719

20+
gulp
21+
.src("./src/*.json")
22+
.pipe(jsonToYaml())
23+
.pipe(gulp.dest("./dist/"));
24+
1825
const browserSync = BrowserSync.create();
1926
const defaultArgs = ["-d", "../dist", "-s", "site", "-v"];
2027

21-
gulp.task("hugo", (cb) => buildSite(cb));
22-
gulp.task("hugo-preview", (cb) => buildSite(cb, ["--buildDrafts", "--buildFuture"]));
28+
gulp.task("hugo", cb => buildSite(cb));
29+
gulp.task("hugo-preview", cb =>
30+
buildSite(cb, ["--buildDrafts", "--buildFuture"])
31+
);
2332

24-
gulp.task("build", ["css", "js", "fonts", "images", "hugo"]);
25-
gulp.task("build-preview", ["css", "js", "fonts", "images", "hugo-preview"]);
33+
gulp.task("build", ["copy", "css", "js", "fonts", "images", "hugo"]);
34+
gulp.task("build-preview", [
35+
"copy",
36+
"css",
37+
"js",
38+
"fonts",
39+
"images",
40+
"hugo-preview"
41+
]);
2642

27-
gulp.task("css", () => (
28-
gulp.src("./src/css/**/*.css")
29-
.pipe(postcss([
30-
cssImport({from: "./src/css/main.css"}),
31-
neatgrid(),
32-
nestedcss(),
33-
colorfunctions(),
34-
hdBackgrounds(),
35-
cssextend(),
36-
cssvars({variables: styleVariables})]))
43+
gulp.task("css", () =>
44+
gulp
45+
.src("./src/css/**/*.css")
46+
.pipe(
47+
postcss([
48+
cssImport({ from: "./src/css/main.css" }),
49+
neatgrid(),
50+
nestedcss(),
51+
colorfunctions(),
52+
hdBackgrounds(),
53+
cssextend(),
54+
cssvars({ variables: styleVariables })
55+
])
56+
)
3757
.pipe(gulp.dest("./dist/css"))
3858
.pipe(browserSync.stream())
39-
));
59+
);
4060

41-
gulp.task("js", (cb) => {
61+
gulp.task("js", cb => {
4262
const myConfig = Object.assign({}, webpackConfig);
4363

4464
webpack(myConfig, (err, stats) => {
4565
if (err) throw new gutil.PluginError("webpack", err);
46-
gutil.log("[webpack]", stats.toString({
47-
colors: true,
48-
progress: true
49-
}));
66+
gutil.log(
67+
"[webpack]",
68+
stats.toString({
69+
colors: true,
70+
progress: true
71+
})
72+
);
5073
browserSync.reload();
5174
cb();
5275
});
5376
});
5477

55-
gulp.task("fonts", () => (
56-
gulp.src("./src/fonts/**/*")
78+
gulp.task("fonts", () =>
79+
gulp
80+
.src("./src/fonts/**/*")
5781
.pipe(gulp.dest("./dist/fonts"))
5882
.pipe(browserSync.stream())
59-
));
83+
);
6084

61-
gulp.task("images", () => (
62-
gulp.src("./src/img/**/*")
85+
gulp.task("images", () =>
86+
gulp
87+
.src("./src/img/**/*")
6388
.pipe(gulp.dest("./dist/img"))
6489
.pipe(browserSync.stream())
65-
));
90+
);
91+
92+
gulp.task("copy", () =>
93+
gulp
94+
.src("../.all-contributorsrc")
95+
.pipe(jsonToYaml())
96+
.pipe(rename("contributors.yml"))
97+
.pipe(gulp.dest("./site/data"))
98+
);
6699

67-
gulp.task("server", ["hugo", "css", "js", "fonts", "images"], () => {
100+
gulp.task("server", ["copy", "hugo", "css", "js", "fonts", "images"], () => {
68101
browserSync.init({
69102
server: {
70103
baseDir: "./dist"
@@ -81,7 +114,7 @@ gulp.task("server", ["hugo", "css", "js", "fonts", "images"], () => {
81114
function buildSite(cb, options) {
82115
const args = options ? defaultArgs.concat(options) : defaultArgs;
83116

84-
return cp.spawn(hugoBin, args, {stdio: "inherit"}).on("close", (code) => {
117+
return cp.spawn(hugoBin, args, { stdio: "inherit" }).on("close", code => {
85118
if (code === 0) {
86119
browserSync.reload();
87120
cb();
@@ -91,4 +124,3 @@ function buildSite(cb, options) {
91124
}
92125
});
93126
}
94-

website/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"file-loader": "^0.9.0",
3232
"gulp": "^3.9.1",
3333
"gulp-babel": "^6.1.2",
34+
"gulp-json-to-yaml": "^0.0.2",
3435
"gulp-postcss": "^6.1.1",
36+
"gulp-rename": "^1.2.2",
3537
"gulp-util": "^3.0.7",
3638
"hugo-bin": "^0.18.0",
3739
"imports-loader": "^0.6.5",

0 commit comments

Comments
 (0)