@redpanda-data/docs-extensions-and-macros 3.5.4 → 3.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/modify-connect-tag-playbook.js +1 -1
- package/extensions/produce-redirects.js +1 -11
- package/extensions/replace-attributes-in-attachments.js +30 -37
- package/extensions/unlisted-pages.js +2 -34
- package/extensions/unpublish-pages.js +1 -4
- package/extensions/version-fetcher/set-latest-version.js +6 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ module.exports.register = function () {
|
|
|
11
11
|
this.replaceFunctions({
|
|
12
12
|
produceRedirects (playbook, aliases) {
|
|
13
13
|
if ('findBy' in aliases) aliases = aliases.findBy({ family: 'alias' }) // @deprecated remove in Antora 4
|
|
14
|
-
if (!aliases.length) return []
|
|
14
|
+
if (!(aliases = aliases.filter((it) => it.pub.url !== it.rel.pub.url)).length) return []
|
|
15
15
|
let siteUrl = playbook.site.url
|
|
16
16
|
if (siteUrl) siteUrl = stripTrailingSlash(siteUrl, '')
|
|
17
17
|
const directoryRedirects = (playbook.urls.htmlExtensionStyle || 'default') !== 'default'
|
|
@@ -32,7 +32,6 @@ module.exports.register = function () {
|
|
|
32
32
|
default:
|
|
33
33
|
return unpublish(aliases)
|
|
34
34
|
}
|
|
35
|
-
return produceRedirectsDelegate.call(this, playbook, aliases)
|
|
36
35
|
}
|
|
37
36
|
})
|
|
38
37
|
})
|
|
@@ -72,7 +71,6 @@ function extractUrlPath (url) {
|
|
|
72
71
|
|
|
73
72
|
function createHttpdHtaccess (files, urlPath, directoryRedirects = false) {
|
|
74
73
|
const rules = files.reduce((accum, file) => {
|
|
75
|
-
if (isRedirectLoop(file)) return accum
|
|
76
74
|
delete file.out
|
|
77
75
|
let fromUrl = file.pub.url
|
|
78
76
|
fromUrl = ~fromUrl.indexOf('%20') ? `'${urlPath}${fromUrl.replace(ENCODED_SPACE_RX, ' ')}'` : urlPath + fromUrl
|
|
@@ -97,7 +95,6 @@ function createHttpdHtaccess (files, urlPath, directoryRedirects = false) {
|
|
|
97
95
|
// however, we keep it when generating the rules for clarity
|
|
98
96
|
function createNetlifyRedirects (files, urlPath, addDirectoryRedirects = false, useForceFlag = true) {
|
|
99
97
|
const rules = files.reduce((accum, file) => {
|
|
100
|
-
if (isRedirectLoop(file)) return accum
|
|
101
98
|
delete file.out
|
|
102
99
|
const fromUrl = urlPath + file.pub.url
|
|
103
100
|
const toUrl = urlPath + file.rel.pub.url
|
|
@@ -117,7 +114,6 @@ function createNetlifyRedirects (files, urlPath, addDirectoryRedirects = false,
|
|
|
117
114
|
|
|
118
115
|
function createNginxRewriteConf (files, urlPath) {
|
|
119
116
|
const rules = files.map((file) => {
|
|
120
|
-
if (isRedirectLoop(file)) return ''
|
|
121
117
|
delete file.out
|
|
122
118
|
let fromUrl = file.pub.url
|
|
123
119
|
fromUrl = ~fromUrl.indexOf('%20') ? `'${urlPath}${fromUrl.replace(ENCODED_SPACE_RX, ' ')}'` : urlPath + fromUrl
|
|
@@ -135,7 +131,6 @@ function createNginxRewriteConf (files, urlPath) {
|
|
|
135
131
|
|
|
136
132
|
function populateStaticRedirectFiles(files, siteUrl) {
|
|
137
133
|
for (const file of files) {
|
|
138
|
-
if (isRedirectLoop(file)) continue
|
|
139
134
|
const content = createStaticRedirectContents(file, siteUrl) + '\n';
|
|
140
135
|
file.contents = Buffer.from(content);
|
|
141
136
|
}
|
|
@@ -166,8 +161,3 @@ function regexpEscape (str) {
|
|
|
166
161
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // don't escape "-" since it's meaningless in a literal
|
|
167
162
|
}
|
|
168
163
|
|
|
169
|
-
function isRedirectLoop (file) {
|
|
170
|
-
if (file.pub.url === file.rel.pub.url) return true
|
|
171
|
-
return false
|
|
172
|
-
}
|
|
173
|
-
|
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
const { family = 'attachment' } = config;
|
|
3
|
-
const logger = this.getLogger('replace-attributes-in-attachments-extension');
|
|
1
|
+
'use strict';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
module.exports.register = function () {
|
|
4
|
+
this.on('contentClassified', ({ contentCatalog }) => {
|
|
5
|
+
const componentVersionTable = contentCatalog.getComponents().reduce((componentMap, component) => {
|
|
6
|
+
componentMap[component.name] = component.versions.reduce((versionMap, componentVersion) => {
|
|
7
|
+
versionMap[componentVersion.version] = componentVersion;
|
|
8
|
+
return versionMap;
|
|
9
|
+
}, {});
|
|
10
|
+
return componentMap;
|
|
11
|
+
}, {});
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const redpandaVersionRegex = /(\$\{REDPANDA_VERSION[^\}]*\})/g;
|
|
27
|
-
const redpandaConsoleVersionRegex = /(\$\{REDPANDA_CONSOLE_VERSION[^\}]*\})/g;
|
|
28
|
-
const fullVersion = asciidoc.attributes['full-version'] ? sanitizeAttributeValue(asciidoc.attributes['full-version']) : '';
|
|
29
|
-
const latestConsoleVersion = asciidoc.attributes['latest-console-version'] ? sanitizeAttributeValue(asciidoc.attributes['latest-console-version']) : '';
|
|
30
|
-
|
|
31
|
-
contentString = contentString.replace(redpandaVersionRegex, fullVersion);
|
|
32
|
-
contentString = contentString.replace(redpandaConsoleVersionRegex, latestConsoleVersion);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
attachment['_contents'] = Buffer.from(contentString, "utf-8");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
13
|
+
contentCatalog.findBy({ family: 'attachment' }).forEach((attachment) => {
|
|
14
|
+
const componentVersion = componentVersionTable[attachment.src.component][attachment.src.version];
|
|
15
|
+
let attributes = componentVersion.asciidoc?.attributes;
|
|
16
|
+
if (!attributes) return;
|
|
17
|
+
attributes = Object.entries(attributes).reduce((accum, [name, val]) => {
|
|
18
|
+
const stringValue = String(val); // Ensure val is a string
|
|
19
|
+
accum[name] = stringValue.endsWith('@') ? stringValue.slice(0, stringValue.length - 1) : stringValue;
|
|
20
|
+
return accum;
|
|
21
|
+
}, {});
|
|
22
|
+
let modified;
|
|
23
|
+
const result = attachment.contents.toString().replace(/\{([\p{Alpha}\d_][\p{Alpha}\d_-]*)\}/gu, (match, name) => {
|
|
24
|
+
if (!(name in attributes)) return match;
|
|
25
|
+
modified = true;
|
|
26
|
+
let value = attributes[name];
|
|
27
|
+
if (value.endsWith('@')) value = value.slice(0, value.length - 1);
|
|
28
|
+
return value;
|
|
29
|
+
});
|
|
30
|
+
if (modified) attachment.contents = Buffer.from(result);
|
|
31
|
+
});
|
|
39
32
|
});
|
|
40
|
-
}
|
|
33
|
+
};
|
|
@@ -7,10 +7,8 @@ module.exports.register = function ({ config }) {
|
|
|
7
7
|
this.on('navigationBuilt', ({ siteCatalog, contentCatalog }) => {
|
|
8
8
|
contentCatalog.getComponents().forEach(({ versions }) => {
|
|
9
9
|
versions.forEach(({ name: component, version, navigation: nav, url: defaultUrl }) => {
|
|
10
|
-
if (component === 'api') return;
|
|
10
|
+
if (component === 'api' || component === 'redpanda-labs') return;
|
|
11
11
|
if (!nav) return;
|
|
12
|
-
const currentComponent = contentCatalog.getComponent(component);
|
|
13
|
-
const prerelease = currentComponent && currentComponent.latestPrerelease ? currentComponent.latestPrerelease : false;
|
|
14
12
|
|
|
15
13
|
const navEntriesByUrl = getNavEntriesByUrl(nav);
|
|
16
14
|
const unlistedPages = contentCatalog
|
|
@@ -30,10 +28,7 @@ module.exports.register = function ({ config }) {
|
|
|
30
28
|
return collector;
|
|
31
29
|
}, []);
|
|
32
30
|
|
|
33
|
-
if (unlistedPages.length &&
|
|
34
|
-
// Some component pages for Redpanda Connect are autogenerated. This function tries to add unlisted component pages to the nav in case a new one gets created without updating the nav.
|
|
35
|
-
addRedpandaConnectPagesToNav(nav[0].items, unlistedPages);
|
|
36
|
-
} else if (unlistedPages.length && addToNavigation) {
|
|
31
|
+
if (unlistedPages.length && addToNavigation) {
|
|
37
32
|
nav.push({
|
|
38
33
|
content: unlistedPagesHeading,
|
|
39
34
|
items: unlistedPages.map((page) => {
|
|
@@ -55,33 +50,6 @@ function getNavEntriesByUrl(items = [], accum = {}) {
|
|
|
55
50
|
return accum;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
function addRedpandaConnectPagesToNav(navItems, pages) {
|
|
59
|
-
// get the Components nav section
|
|
60
|
-
let componentsSection = navItems.find(item => item.content === 'Components');
|
|
61
|
-
if (!componentsSection) return;
|
|
62
|
-
|
|
63
|
-
pages.forEach(page => {
|
|
64
|
-
const dirname = page.out.dirname;
|
|
65
|
-
if (!dirname.includes('/components/')) return;
|
|
66
|
-
const heading = page.asciidoc.attributes.doctitle;
|
|
67
|
-
const pathParts = dirname.split('/').slice(2); // Get the type
|
|
68
|
-
// get existing nav items inside the Components tree
|
|
69
|
-
let currentLevel = componentsSection.items;
|
|
70
|
-
|
|
71
|
-
pathParts.forEach((part, index) => {
|
|
72
|
-
const capitalizedPart = part.charAt(0).toUpperCase() + part.slice(1);
|
|
73
|
-
let section = currentLevel.find(item => item.content === capitalizedPart);
|
|
74
|
-
if (!section) {
|
|
75
|
-
section = { content: capitalizedPart, items: [], root: index === 0 };
|
|
76
|
-
currentLevel.push(section);
|
|
77
|
-
}
|
|
78
|
-
currentLevel = section.items;
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
currentLevel.push({ content: page.asciidoc.navtitle || page.src.stem, url: page.pub.url, urlType: 'internal' });
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
53
|
function removePageFromNav(navItems, urlToRemove) {
|
|
86
54
|
// Remove the page from the navigation items
|
|
87
55
|
for (let i = navItems.length - 1; i >= 0; i--) {
|
|
@@ -14,14 +14,11 @@ module.exports.register = function () {
|
|
|
14
14
|
pageVersion = page.asciidoc?.attributes['page-component-version'];
|
|
15
15
|
const component = contentCatalog.getComponent(componentName);
|
|
16
16
|
|
|
17
|
-
// Check if the page is part of the beta version
|
|
18
|
-
const isPrerelease = component && pageVersion && component.latestPrerelease && component.latestPrerelease.version === pageVersion;
|
|
19
|
-
|
|
20
17
|
// Check the conditions for unpublishing the page
|
|
21
18
|
const shouldUnpublish = (
|
|
22
19
|
page.asciidoc?.attributes['page-unpublish'] ||
|
|
23
20
|
(page.asciidoc?.attributes['publish-only-during-beta']
|
|
24
|
-
&& !
|
|
21
|
+
&& !page.asciidoc?.attributes['page-component-version-is-prerelease'] // Not part of a beta version, meaning the beta period has ended
|
|
25
22
|
)
|
|
26
23
|
);
|
|
27
24
|
|
|
@@ -30,7 +30,13 @@ module.exports.register = function ({ config }) {
|
|
|
30
30
|
|
|
31
31
|
const components = await contentCatalog.getComponents()
|
|
32
32
|
components.forEach(component => {
|
|
33
|
+
let prerelease = component.latestPrerelease;
|
|
33
34
|
component.versions.forEach(({ name, version, asciidoc }) => {
|
|
35
|
+
// This attribute is used for conditionally rendering content for beta releases.
|
|
36
|
+
// It is also used in the `unpublish-pages` extension to unpublish beta pages that aren't part of a beta version.
|
|
37
|
+
if (prerelease && prerelease.version === version) {
|
|
38
|
+
asciidoc.attributes['page-component-version-is-prerelease'] = 'true'
|
|
39
|
+
}
|
|
34
40
|
if (LatestConsoleVersion) {
|
|
35
41
|
asciidoc.attributes['latest-console-version'] = `${LatestConsoleVersion}@`
|
|
36
42
|
logger.info(`Set Redpanda Console version to ${LatestConsoleVersion} in ${name} ${version}`)
|