diff --git a/lib/antora/extensions/version-fix.js b/lib/antora/extensions/version-fix.js index e6baf669c5..788d2b0192 100644 --- a/lib/antora/extensions/version-fix.js +++ b/lib/antora/extensions/version-fix.js @@ -1,39 +1,22 @@ -// https://gitlab.com/antora/antora/-/issues/132#note_712132072 'use strict' - -module.exports.register = function({ config }) { - this.on('contentAggregated', ({ contentAggregate }) => { - contentAggregate.forEach(aggregate => { - if (aggregate.name === "" && aggregate.displayVersion === 5.6) { - aggregate.name = "ROOT"; - aggregate.version = "5.6.0-RC1" - aggregate.startPage = "ROOT:index.adoc" - aggregate.displayVersion = `${aggregate.version}` - aggregate.prerelease = true - } - else if (aggregate.version === "5.6.1" && - aggregate.prerelease == "-SNAPSHOT") { - aggregate.version = "5.6.1" - aggregate.displayVersion = `${aggregate.version}` - aggregate.prerelease = true - } - else if (aggregate.prerelease && aggregate.prerelease != true) { - aggregate.version += aggregate.prerelease - aggregate.prerelease = true - } - }) +module.exports.register = function () { + this.once('contentAggregated', ({ contentAggregate }) => { + contentAggregate.forEach((componentVersionBucket) => { + if (componentVersionBucket.prerelease === 'true') componentVersionBucket.prerelease = true + if (!componentVersionBucket.name && componentVersionBucket.displayVersion === '5.6') { + componentVersionBucket.name = 'ROOT' + componentVersionBucket.version = '5.6.0-RC1' + delete componentVersionBucket.displayVersion + componentVersionBucket.prerelease = true + } + else if (componentVersionBucket.version === '5.6.1') { + delete componentVersionBucket.prerelease + } + else if (typeof componentVersionBucket.prerelease === 'string' && componentVersionBucket.prerelease !== '-SNAPSHOT') { + componentVersionBucket.version += componentVersionBucket.prerelease + componentVersionBucket.prerelease = true + } }) -} - -function out(args) { - console.log(JSON.stringify(args, no_data, 2)); -} - - -function no_data(key, value) { - if (key == "data" || key == "files") { - return value ? "__data__" : value; - } - return value; + }) }