Skip to content

Commit

Permalink
Add antora-ui-version meta element
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rwinch committed May 17, 2024
1 parent 6b3b45f commit 6f7d82c
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 3 deletions.
6 changes: 5 additions & 1 deletion gulp.d/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ const postcssUrl = require('postcss-url')
const postcssVar = require('postcss-custom-properties')
const { Transform } = require('stream')
const map = (transform) => new Transform({ objectMode: true, transform })
const replace = require('gulp-replace')
const through = () => map((file, enc, next) => next(null, file))
const uglify = require('gulp-uglify')
const vfs = require('vinyl-fs')
const git = require('git-rev-sync')

module.exports = (src, dest, preview) => () => {
const opts = { base: src, cwd: src }
Expand Down Expand Up @@ -101,7 +103,9 @@ module.exports = (src, dest, preview) => () => {
vfs.src('helpers/*.js', opts),
vfs.src('layouts/*.hbs', opts),
vfs.src('partials/*.hbs', opts)
).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' }))
.pipe(replace('@@antora-ui-version', git.isTagDirty() ? git.long() : git.tag()))
).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' })
)
}

function bundle ({ base: basedir, ext: bundleExt = '.bundle.js' }) {
Expand Down
141 changes: 140 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
"eslint-plugin-promise": "~4.2",
"eslint-plugin-standard": "~4.0",
"fancy-log": "~2.0",
"git-rev-sync": "^3.0.2",
"gulp": "~4.0",
"gulp-concat": "~2.6",
"gulp-connect": "~5.7",
"gulp-eslint": "~6.0",
"gulp-imagemin": "~6.2",
"gulp-postcss": "~9.0",
"gulp-replace": "~1.1",
"gulp-stylelint": "~13.0",
"gulp-uglify": "~3.0",
"gulp-vinyl-zip": "~2.5",
Expand All @@ -69,6 +71,7 @@
},
"dependencies": {
"@algolia/client-search": "^4.17.0",
"@primer/octicons": "^19.8.0"
"@primer/octicons": "^19.8.0",
"init": "^0.1.2"
}
}
1 change: 1 addition & 0 deletions src/partials/head-meta.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{!-- Add additional meta tags here --}}
<meta name="antora-ui-version" content="@@antora-ui-version"> {{!-- replaced by the gulp build --}}
<meta name="version" content="{{{page.version}}}">
<meta name="component" content="{{{page.component.name}}}">
<meta name="latest-version" content="{{~#if (and page.latest (eq page.url page.latest.url))}}true{{~else}}false{{~/if}}">

0 comments on commit 6f7d82c

Please sign in to comment.