summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Allen <dan@opendevise.com>2018-12-31 19:22:23 -0700
committerDan Allen <dan@opendevise.com>2018-12-31 19:22:23 -0700
commit2fc25c6e3fab0f11914561e801a92240e3b751ff (patch)
tree0b358a12f0815105b3c2a6f027d727ea1e7b1ebf
parentce962886377bf2baa8e5dd8e24d1df3126295a79 (diff)
downloadalpine-antora-theme-2fc25c6e3fab0f11914561e801a92240e3b751ff.tar.bz2
alpine-antora-theme-2fc25c6e3fab0f11914561e801a92240e3b751ff.tar.xz
format source code
-rw-r--r--gulpfile.js/tasks/build.js16
-rw-r--r--gulpfile.js/tasks/preview-pages.js75
2 files changed, 52 insertions, 39 deletions
diff --git a/gulpfile.js/tasks/build.js b/gulpfile.js/tasks/build.js
index 76e48d7..fa75b08 100644
--- a/gulpfile.js/tasks/build.js
+++ b/gulpfile.js/tasks/build.js
@@ -60,12 +60,16 @@ module.exports = (src, dest, preview) => () => {
.pipe(uglify()),
vfs.src('css/site.css', opts).pipe(postcss(postcssPlugins)),
vfs.src('font/*.woff*(2)', opts),
- vfs.src('img/**/*.{jpg,ico,png,svg}', opts).pipe(imagemin([
- imagemin.gifsicle(),
- imagemin.jpegtran(),
- imagemin.optipng(),
- imagemin.svgo({ plugins: [{ removeViewBox: false }] }),
- ])),
+ vfs
+ .src('img/**/*.{jpg,ico,png,svg}', opts)
+ .pipe(
+ imagemin([
+ imagemin.gifsicle(),
+ imagemin.jpegtran(),
+ imagemin.optipng(),
+ imagemin.svgo({ plugins: [{ removeViewBox: false }] }),
+ ])
+ ),
vfs.src('helpers/*.js', opts),
vfs.src('layouts/*.hbs', opts),
vfs.src('partials/*.hbs', opts)
diff --git a/gulpfile.js/tasks/preview-pages.js b/gulpfile.js/tasks/preview-pages.js
index c31a5c1..12f3219 100644
--- a/gulpfile.js/tasks/preview-pages.js
+++ b/gulpfile.js/tasks/preview-pages.js
@@ -21,40 +21,49 @@ const ASCIIDOC_ATTRIBUTES = {
module.exports = (src, previewSrc, previewDest, sink = () => map(), layouts = {}) => () =>
Promise.all([
loadSampleUiModel(previewSrc),
- toPromise(merge(compileLayouts(src, layouts), registerPartials(src), registerHelpers(src), copyImages(previewSrc, previewDest))),
- ]).then(([baseUiModel]) => Object.assign(baseUiModel, { env: process.env })).then((baseUiModel) =>
- vfs
- .src('**/*.adoc', { base: previewSrc, cwd: previewSrc })
- .pipe(
- map((file, enc, next) => {
- const siteRootPath = path.relative(ospath.dirname(file.path), ospath.resolve(previewSrc))
- const uiModel = Object.assign({}, baseUiModel)
- uiModel.page = Object.assign({}, uiModel.page)
- uiModel.siteRootPath = siteRootPath
- uiModel.siteRootUrl = path.join(siteRootPath, 'index.html')
- uiModel.uiRootPath = path.join(siteRootPath, '_')
- if (file.stem === '404') {
- uiModel.page = { layout: '404', title: 'Page Not Found' }
- } else {
- const doc = asciidoctor.load(file.contents, { safe: 'safe', attributes: ASCIIDOC_ATTRIBUTES })
- uiModel.page.attributes = Object.entries(doc.getAttributes())
- .filter(([name, val]) => name.startsWith('page-'))
- .reduce((accum, [name, val]) => {
- accum[name.substr(5)] = val
- return accum
- }, {})
- uiModel.page.layout = doc.getAttribute('page-layout', 'default')
- uiModel.page.title = doc.getDocumentTitle()
- uiModel.page.contents = Buffer.from(doc.convert())
- }
- file.extname = '.html'
- file.contents = Buffer.from(layouts[uiModel.page.layout](uiModel))
- next(null, file)
- })
+ toPromise(
+ merge(
+ compileLayouts(src, layouts),
+ registerPartials(src),
+ registerHelpers(src),
+ copyImages(previewSrc, previewDest)
)
- .pipe(vfs.dest(previewDest))
- .pipe(sink())
- )
+ ),
+ ])
+ .then(([baseUiModel]) => Object.assign(baseUiModel, { env: process.env }))
+ .then((baseUiModel) =>
+ vfs
+ .src('**/*.adoc', { base: previewSrc, cwd: previewSrc })
+ .pipe(
+ map((file, enc, next) => {
+ const siteRootPath = path.relative(ospath.dirname(file.path), ospath.resolve(previewSrc))
+ const uiModel = Object.assign({}, baseUiModel)
+ uiModel.page = Object.assign({}, uiModel.page)
+ uiModel.siteRootPath = siteRootPath
+ uiModel.siteRootUrl = path.join(siteRootPath, 'index.html')
+ uiModel.uiRootPath = path.join(siteRootPath, '_')
+ if (file.stem === '404') {
+ uiModel.page = { layout: '404', title: 'Page Not Found' }
+ } else {
+ const doc = asciidoctor.load(file.contents, { safe: 'safe', attributes: ASCIIDOC_ATTRIBUTES })
+ uiModel.page.attributes = Object.entries(doc.getAttributes())
+ .filter(([name, val]) => name.startsWith('page-'))
+ .reduce((accum, [name, val]) => {
+ accum[name.substr(5)] = val
+ return accum
+ }, {})
+ uiModel.page.layout = doc.getAttribute('page-layout', 'default')
+ uiModel.page.title = doc.getDocumentTitle()
+ uiModel.page.contents = Buffer.from(doc.convert())
+ }
+ file.extname = '.html'
+ file.contents = Buffer.from(layouts[uiModel.page.layout](uiModel))
+ next(null, file)
+ })
+ )
+ .pipe(vfs.dest(previewDest))
+ .pipe(sink())
+ )
function loadSampleUiModel (src) {
return fs.readFile(ospath.join(src, 'ui-model.yml'), 'utf8').then((contents) => yaml.safeLoad(contents))