Skip to content

Commit 8245f1c

Browse files
committed
Different AuthenticatedContentPlaceholder depending on version
1 parent 5aa5de5 commit 8245f1c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

scripts/source/bdr.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const fileToMetadata = {};
2222
const basePath = path.resolve("temp_bdr/docs/docs2/");
2323
const imgPath = path.resolve("temp_bdr/docs/img/");
2424

25+
2526
(async () => {
2627
const processor = unified()
2728
.use(remarkParse)
@@ -51,7 +52,7 @@ const imgPath = path.resolve("temp_bdr/docs/img/");
5152
const mdIndex = yaml.load(await fs.readFile(path.resolve(basePath, "bdr-pub.yml"), 'utf8'));
5253

5354
const markdownToProcess = mdIndex.nav; //await glob("temp_bdr/**/*.md");
54-
const version = mdIndex.site_name.match(/BDR (\d+\.\d+)/)[1];
55+
version = mdIndex.site_name.match(/BDR (\d+\.\d+)/)[1];
5556
const destPath = path.resolve("product_docs", "docs", "bdr", version);
5657
const indexFilename = "index.md";
5758

@@ -119,10 +120,17 @@ function bdrTransformer() {
119120
if (node.type === "jsx" && node.value.match(/^<AuthenticatedContentPlaceholder/) )
120121
{
121122
// todo: use HAST parser here
122-
if (!title)
123-
title = node.value.match(/topic="([^"]+)"/)[1];
124-
description = (node.value.match(/description="([^"]+)"/)||[])[1];
125-
node.value = node.value.replace("<AuthenticatedContentPlaceholder", `<AuthenticatedContentPlaceholder target="https://documentation.enterprisedb.com/bdr4/release/latest/${filename.replace(".md", "/")}"`);
123+
if (!title)
124+
{
125+
title = node.value.match(/topic="([^"]+)"/)[1];
126+
}
127+
description = (node.value.match(/description="([^"]+)"/)||[])[1];
128+
if (parseFloat(version) < 4)
129+
{
130+
node.value = node.value.replace("<AuthenticatedContentPlaceholder", `<AuthenticatedContentPlaceholder target="https://documentation.2ndquadrant.com/bdr3-enterprise/release/latest/${filename.replace(".md", "/")}"`)
131+
} else {
132+
node.value = node.value.replace("<AuthenticatedContentPlaceholder", `<AuthenticatedContentPlaceholder target="https://documentation.enterprisedb.com/bdr4/release/latest/${filename.replace(".md", "/")}"`)
133+
}
126134
}
127135
}
128136

0 commit comments

Comments
 (0)