Skip to content

Commit 58e25cf

Browse files
committed
add local build in cloud-docs
1 parent 077f80d commit 58e25cf

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

antora-playbook.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
site:
2+
title: "Cloud Doc Test"
3+
start_page: "cloud4:overview:index.adoc"
4+
5+
content:
6+
sources:
7+
- url: .
8+
branches: HEAD
9+
start_paths: [modules/cloud4, modules/cloud]
10+
11+
output:
12+
dir: ./build/site
13+
14+
ui:
15+
bundle:
16+
url: https://github.com/tigergraph/antora-ui/blob/main/build/ui-bundle.zip?raw=true
17+
snapshot: true

gulpfile.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict'
2+
3+
const connect = require('gulp-connect')
4+
const fs = require('fs')
5+
const generator = require('@antora/site-generator-default')
6+
const { reload: livereload } = process.env.LIVERELOAD === 'true' ? require('gulp-connect') : {}
7+
const { series, src, watch } = require('gulp')
8+
const yaml = require('js-yaml')
9+
10+
const playbookFilename = 'antora-playbook.yml'
11+
const playbook = yaml.load(fs.readFileSync(playbookFilename, 'utf8'))
12+
const outputDir = (playbook.output || {}).dir || './build/site'
13+
const serverConfig = { name: 'Preview Site', livereload, port: 5000, root: outputDir }
14+
const antoraArgs = ['--playbook', playbookFilename]
15+
const watchPatterns = playbook.content.sources.filter((source) => !source.url.includes(':')).reduce((accum, source) => {
16+
accum.push(`${source.url}/${source.start_path ? source.start_path + '/' : ''}antora.yml`)
17+
accum.push(`${source.url}/${source.start_path ? source.start_path + '/' : ''}**/*.adoc`)
18+
return accum
19+
}, [])
20+
21+
function generate (done) {
22+
generator(antoraArgs, process.env)
23+
.then(() => done())
24+
.catch((err) => {
25+
console.log(err)
26+
done()
27+
})
28+
}
29+
30+
function serve (done) {
31+
connect.server(serverConfig, function () {
32+
this.server.on('close', done)
33+
watch(watchPatterns, generate)
34+
if (livereload) watch(this.root).on('change', (filepath) => src(filepath, { read: false }).pipe(livereload()))
35+
})
36+
}
37+
38+
module.exports = { serve, generate, default: series(generate, serve) }

package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "cloud-docs",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "antora generate --fetch antora-playbook.yml",
9+
"dev": "gulp",
10+
"serve": "http-server build/site -c-1"
11+
},
12+
"author": "",
13+
"license": "ISC",
14+
"dependencies": {
15+
"@antora/cli": "^3.1.1",
16+
"@antora/site-generator-default": "^3.1.1",
17+
"gulp": "^4.0.2",
18+
"gulp-cli": "^2.3.0",
19+
"gulp-connect": "^5.7.0",
20+
"js-yaml": "^4.1.0"
21+
}
22+
}

0 commit comments

Comments
 (0)