diff --git a/antora-playbook.yml b/antora-playbook.yml index 2f11a3c11..185213d41 100644 --- a/antora-playbook.yml +++ b/antora-playbook.yml @@ -3,6 +3,7 @@ antora: - require: '@springio/antora-extensions' root_component_name: 'shell' - require: '@springio/antora-extensions/asciinema-extension' + - require: './lib/antora/version-fix.js' site: title: Spring Shell url: https://docs.spring.io/spring-shell/reference diff --git a/lib/antora/version-fix.js b/lib/antora/version-fix.js new file mode 100644 index 000000000..5c8bf217a --- /dev/null +++ b/lib/antora/version-fix.js @@ -0,0 +1,23 @@ +'use strict' + +module.exports.register = function () { + const logger = this.getLogger('version-fix') + this.once('contentAggregated', ({ contentAggregate }) => { + contentAggregate.forEach((componentVersionBucket) => { + logger.info(`tag=${componentVersionBucket.origins[0].tag} version=${componentVersionBucket.version}`) + // if it is a tag and a -SNAPSHOT release + if (componentVersionBucket.origins[0].tag && componentVersionBucket.prerelease === '-SNAPSHOT') { + // remove prerelease: -SNAPSHOT so it appears as a release + delete componentVersionBucket.prerelease + // If asciidoctor attribute name ends with -version, then remove -SNAPSHOT suffix (if present) + const attrs = componentVersionBucket.asciidoc.attributes + for (const [name, value] of Object.entries(attrs)) { + if (name.endsWith('-version') && value.endsWith('-SNAPSHOT')) { + attrs[name] = value.split('-SNAPSHOT').shift() + logger.info(`Changing asciidoctor attr ${name} from ${value} to ${attrs[name]}`) + } + } + } + }) + }) +}