Skip to content

Commit 6f7d82c

Browse files
committed
Add antora-ui-version meta element
Used to test rm -rf build; gulp bundle && cat public/_/partials/head-meta.hbs && unzip -q build/*.zip -d build && cat build/partials/head-meta.hbs Closes gh-245
1 parent 6b3b45f commit 6f7d82c

File tree

4 files changed

+150
-3
lines changed

4 files changed

+150
-3
lines changed

gulp.d/tasks/build.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ const postcssUrl = require('postcss-url')
1717
const postcssVar = require('postcss-custom-properties')
1818
const { Transform } = require('stream')
1919
const map = (transform) => new Transform({ objectMode: true, transform })
20+
const replace = require('gulp-replace')
2021
const through = () => map((file, enc, next) => next(null, file))
2122
const uglify = require('gulp-uglify')
2223
const vfs = require('vinyl-fs')
24+
const git = require('git-rev-sync')
2325

2426
module.exports = (src, dest, preview) => () => {
2527
const opts = { base: src, cwd: src }
@@ -101,7 +103,9 @@ module.exports = (src, dest, preview) => () => {
101103
vfs.src('helpers/*.js', opts),
102104
vfs.src('layouts/*.hbs', opts),
103105
vfs.src('partials/*.hbs', opts)
104-
).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' }))
106+
.pipe(replace('@@antora-ui-version', git.isTagDirty() ? git.long() : git.tag()))
107+
).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' })
108+
)
105109
}
106110

107111
function bundle ({ base: basedir, ext: bundleExt = '.bundle.js' }) {

package-lock.json

Lines changed: 140 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
"eslint-plugin-promise": "~4.2",
4040
"eslint-plugin-standard": "~4.0",
4141
"fancy-log": "~2.0",
42+
"git-rev-sync": "^3.0.2",
4243
"gulp": "~4.0",
4344
"gulp-concat": "~2.6",
4445
"gulp-connect": "~5.7",
4546
"gulp-eslint": "~6.0",
4647
"gulp-imagemin": "~6.2",
4748
"gulp-postcss": "~9.0",
49+
"gulp-replace": "~1.1",
4850
"gulp-stylelint": "~13.0",
4951
"gulp-uglify": "~3.0",
5052
"gulp-vinyl-zip": "~2.5",
@@ -69,6 +71,7 @@
6971
},
7072
"dependencies": {
7173
"@algolia/client-search": "^4.17.0",
72-
"@primer/octicons": "^19.8.0"
74+
"@primer/octicons": "^19.8.0",
75+
"init": "^0.1.2"
7376
}
7477
}

src/partials/head-meta.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{!-- Add additional meta tags here --}}
2+
<meta name="antora-ui-version" content="@@antora-ui-version"> {{!-- replaced by the gulp build --}}
23
<meta name="version" content="{{{page.version}}}">
34
<meta name="component" content="{{{page.component.name}}}">
45
<meta name="latest-version" content="{{~#if (and page.latest (eq page.url page.latest.url))}}true{{~else}}false{{~/if}}">

0 commit comments

Comments
 (0)