forked from apache/camel-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (57 loc) · 1.93 KB
/
gulpfile.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
const cheerio = require('gulp-cheerio');
const env = process.env.CAMEL_ENV || 'development';
const gulp = require('gulp');
const htmlmin = require('gulp-htmlmin');
/**
* We minify all HTML files using htmlmin, this is to make them smaller in size
* as we generate quite big HTML files in the documentation. We do not do this
* unless the environment variable `CAMEL_ENV` is set to 'production' to help
* with the development turnaround as this takes quite a while to do.
*/
gulp.task('minify', (done) => {
if (env !== 'production') {
done();
return;
}
return gulp.src('public/**/*.html')
.pipe(htmlmin({
collapseBooleanAttributes: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
conservativeCollapse: true,
useShortDoctype: true,
processScripts: ['application/ld+json']
}))
.pipe(gulp.dest('public'));
});
/*
* Appends `sitemap-website.xml` to the `sitemap.xml`.
*
* We have sitemaps generated by Antora for each documentation component, these
* are generated in `documentation/sitemap-*.xml` along with the
* `documentation/sitemap.xml` that is a sitemap index pointing to each
* component sitemap.
*
* Hugo also generates a sitemap in `public/sitemap-website.xml` containing all
* pages generated from `content/` and other sources. We need to add the
* `sitemap-website.xml` to the `sitemap.xml` so that we have a sitemap index
* containing pointers to all individual sitemaps.
*
* Sitemaps are used by search engines (Google, Algolia, ...) to help them crawl
* and index the website.
*/
gulp.task('sitemap', (done) => {
return gulp.src('public/sitemap.xml')
.pipe(cheerio(($, f) =>
$('sitemapindex').append(`<sitemap>
<loc>https://camel.apache.org/sitemap-website.xml</loc>
</sitemap>`)
))
.pipe(gulp.dest('public'));
});
/*
* Removes the content from the `public` directory.
*/
gulp.task('clean', () => {
return require('del')('public');
});