@redpanda-data/docs-extensions-and-macros
Advanced tools
Comparing version 3.5.5 to 3.5.6
'use strict'; | ||
module.exports.register = function () { | ||
const sanitizeAttributeValue = (value) => String(value).replace("@", ""); | ||
this.on('contentClassified', ({ contentCatalog }) => { | ||
@@ -23,3 +24,19 @@ const componentVersionTable = contentCatalog.getComponents().reduce((componentMap, component) => { | ||
let modified; | ||
const result = attachment.contents.toString().replace(/\{([\p{Alpha}\d_][\p{Alpha}\d_-]*)\}/gu, (match, name) => { | ||
let contentString = attachment.contents.toString(); | ||
// Specific replacements for YAML files | ||
if (attachment.out.path.endsWith('.yaml') || attachment.out.path.endsWith('.yml')) { | ||
const redpandaVersionRegex = /(\$\{REDPANDA_VERSION[^\}]*\})/g; | ||
const redpandaConsoleVersionRegex = /(\$\{REDPANDA_CONSOLE_VERSION[^\}]*\})/g; | ||
let fullVersion = attributes['full-version'] ? sanitizeAttributeValue(attributes['full-version']) : ''; | ||
const latestConsoleVersion = attributes['latest-console-version'] ? sanitizeAttributeValue(attributes['latest-console-version']) : ''; | ||
if (attributes['page-component-version-is-prerelease'] === 'true') { | ||
fullVersion = attributes['redpanda-beta-version'] ? sanitizeAttributeValue(attributes['redpanda-beta-version']) : fullVersion; | ||
} | ||
contentString = contentString.replace(redpandaVersionRegex, fullVersion); | ||
contentString = contentString.replace(redpandaConsoleVersionRegex, latestConsoleVersion); | ||
} | ||
const result = contentString.replace(/\{([\p{Alpha}\d_][\p{Alpha}\d_-]*)\}/gu, (match, name) => { | ||
if (!(name in attributes)) return match; | ||
@@ -31,2 +48,3 @@ modified = true; | ||
}); | ||
if (modified) attachment.contents = Buffer.from(result); | ||
@@ -33,0 +51,0 @@ }); |
{ | ||
"name": "@redpanda-data/docs-extensions-and-macros", | ||
"version": "3.5.5", | ||
"version": "3.5.6", | ||
"description": "Antora extensions and macros developed for Redpanda documentation.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
108759
1889
645